0

I'm using MagickNet (ImageMagick for .NET) to read the SVG code below, which contains a valid character from the "Symbol" true type font on Windows. The character is UF0B7 (uniF0B7 in the cmap table of the symbol.ttf font). This is a filled circle. The image I get using ImageMagick contains a rectangle with F0B7 written inside.

Here is my SVG file containing this special character. It is inside the text XML element (you might see it as a small square on your browser):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="main1" width="960" height="720">
    <g transform="matrix(1.3333334 0 0 1.3333334 0 0)">
        <path stroke="none" fill="#FFFFFF" fill-rule="evenodd" d="M0 0L720 0L720 540L0 540z" transform="matrix(1 0 0 1 0 0)"  />
        <text style="fill:#000000;font-family:Symbol;" font-size="32" transform="matrix(1 0 0 1 43.08661 129.5433)" fill-opacity="1" x="0.028347015" y="29.952" letter-spacing="-0.01"></text>
    </g>
</svg>

Here is my C# code:

byte[] imageData = File.ReadAllBytes(@"F:\test.svg");
using MagickImage image = new MagickImage(imageData);
image.Write(@"F:\test.jpg");

Is there a way to make ImageMagick use the system's Symbol font with such private use characters (according to the unicode standard) ? This character and others of the same kind are often used by Powerpoint software for bullets. I need, in my own software, to convert pptx slides to svgs using available libraries, and then rework them, isolate paragraphs in separate SVGs, to produce slide animation. In order to convert the final SVGs to images, I could also use other libraries like SVG.Net, but this one has other problems too. Up to now, MagickNet is the most precise one, except for this problem.

Steph555
  • 21
  • 1
  • 4
  • What's wrong on common (non-private use) Unicode characters like ⚪ U+26AA Medium White Circle | ⚫ U+26AB Medium Black Circle | ⬤ U+2B24 Black Large Circle | ● U+25CF Black Circle ? – JosefZ Aug 27 '21 at 21:06
  • Please [edit] your question to share a [mcve]. BTW, that character is named `uniF0B7` in the `cmap` table of the `symbol.ttf` font… – JosefZ Aug 28 '21 at 09:01
  • Thank you. I have edited my question and added some precisions, like why I need this specific character and others of the same kind, since they are used for Powerpoint bullets. – Steph555 Aug 28 '21 at 17:47
  • _BTW, that character is named uniF0B7 in the cmap table of the symbol.ttf font…_ Actually, not technically true. The cmap table provides a mapping from characters to glyphs, but it uses numeric character and glyph IDs, not names. If a font has glyph names, those would be in the 'post' table, but symbol.ttf has a format 3 'post' table without any glyph names. Also, a cmap table indicates a character encoding, and in symbol.ttf the character encoding indicated by the cmap table is not Unicode but rather is the "Windows symbol" encoding; so "uni" isn't strictly applicable. – Peter Constable Aug 28 '21 at 17:53
  • Please explain what exact functionality it is you want to achieve. You've described your attempt at an implementation, but there may be a simpler approach. In particular, creating an SVG file with a text element that displays a small circle, then using a library to convert that to a JPEG image seems convoluted if what you want to achieve is to display a bullet in text content such as a presentation slide. – Peter Constable Aug 28 '21 at 18:03
  • Done, at the end of my question. – Steph555 Aug 28 '21 at 18:21
  • @PeterConstable disagree. If I use (simplified code) `from fontTools.ttLib import TTFont; fontpath=r'C:\WINDOWS\Fonts\symbol.ttf'; font = TTFont(fontpath)` then `font['cmap'].tables[1].cmap[0xF0B7]` returns `'uniF0B7'` and `'uniF0B7' in font.getGlyphNames()` returns `True` and `font.getGlyphID('uniF0FE')` returns `191`. No _flame war_… – JosefZ Aug 28 '21 at 21:01
  • @JosefZ: No flame war intended. Fonttools will report glyph names because it disassembles to a format that **requires** glyph names, and so it generates those glyph names. I edit the [OpenType spec](https://learn.microsoft.com/en-us/typography/opentype/spec/); I know the format quite well, and have looked at the font. If a font contains glyph names, those are in a format 2 'post' table. The symbol.ttf font has a format 3 'post' table, which does not have any glyphs names. The 'cmap' table uses platform 3, encoding 0, which is "Windows symbol", not Unicode. – Peter Constable Aug 29 '21 at 19:50

0 Answers0