Forum > LazUtils
About fpttf and fpparsettf
MNeto:
Hello.
In this topic:
http://forum.lazarus.freepascal.org/index.php/topic,33141.0.html
I learned about the units fpdf and fpparsettf (fcl-pdf), created by Graeme.
I have two questions:
1. It is possible get a unicode character that matches the one GlyphID?
2. (This question is not directly related to fpparsettf but the FreePascal). Some fonts have characters that are outside the Basic Multilingual Plane, as #$1D435. fpparsettf can handle it normally, since it accesses the font directly. But I can not display these characters using the Free Pascal (I think it only supports Basic Multilingual Plane). Is there any way around this limitation?
Thanks!
engkin:
--- Quote from: MNeto on July 12, 2016, 11:26:15 pm ---1. It is possible get a unicode character that matches the one GlyphID?
--- End quote ---
In general, IIRC, more than one unicode character could point to one GlyphID.
The data you are looking for is in a table called CMAP. Its function is to find GlyphIDs from character codes in a font file, that is the opposite to what you are trying to do.
TTFFileInfo in fpparsettf parses CMAP and stores the result in CMapH and dynamic array Chars.
--- Quote from: MNeto on July 12, 2016, 11:26:15 pm ---2. (This question is not directly related to fpparsettf but the FreePascal). Some fonts have characters that are outside the Basic Multilingual Plane, as #$1D435. fpparsettf can handle it normally, since it accesses the font directly.
--- End quote ---
It can but it does not. The parser in fpparsettf unit, last time I checked, supports format 4 of platform 3 and encoding 1. That is Windows fonts with Unicode BMP encoding. To support non-BMP encoding it needs format 12 at least.
--- Quote from: MNeto on July 12, 2016, 11:26:15 pm ---But I can not display these characters using the Free Pascal (I think it only supports Basic Multilingual Plane). Is there any way around this limitation?
--- End quote ---
If the font you are using does not have that character, FPC can not change that fact. I don't seem to have a font that includes MATHEMATICAL ITALIC CAPITAL B (#$1D435)
Show your code.
MNeto:
Thanks for answering.
--- Quote ---In general, IIRC, more than one unicode character could point to one GlyphID.
--- End quote ---
Curious. I assumed every GlyphID corresponds a single unicode value ...
--- Quote ---If the font you are using does not have that character, FPC can not change that fact. I don't seem to have a font that includes MATHEMATICAL ITALIC CAPITAL B (#$1D435)
--- End quote ---
In fact, some OpenType specialized fonts already have these characters. For example, XITSMath font. The range is 'Mathematical Alphanumeric Symbols'.
When I try to assign the escape sequence #$1D435, or its corresponding decimal #119861, I get the error 'illegal char constant', because the sequence is outside the range allowed.
Characters of this type would already be in the scope of UTF16...
The most I could do was find routines that convert some values in UTF16 to UTF8, but for this range of characters that will not work, because characters like #$1D435 does not have correspondent in UTF8.
MNeto:
I solved the problem of attribution using the following code. But printing of the character is incorrect.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var c : WideString; ... {c := #$1D435; // don't work}c := WideChar($1D4A5); //OKLabel1.Caption := c;
The Label control is with the XITS Math font. The code compiles, but the printed character is incorrect.
engkin:
Make sure the label is using XITSMath font:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses LazUTF8;...var s: string;... s := UnicodeToUTF8($1D435); Label1.Caption := s;
Lazarus uses UTF8 encoding.
Navigation
[0] Message Index
[#] Next page