Recent

Author Topic: [Solved][LazFreeType]How to interpolate a point not on the curve?  (Read 30258 times)

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #15 on: February 24, 2013, 09:16:41 pm »
circular
>>You need to deactivate font hinting (Hinted property).
Thank you. it works.
There was one more question.
I need the ttf fonts in vector editor, so DPI for me does not matter. When loading fonts I divide the coordinates of glyphs on the font size, and expect to receive a letter of unit height:
Code: [Select]
k:=1/ftFont.SizeInPoints;
...
CoordInMyEditor.x:=k*_glyph^.outline.points^[j].x/64;
CoordInMyEditor.y:=k*_glyph^.outline.points^[j].y/64;
...
In fact, I get a little smaller, and for each font, it's different.
By experimenting, I found to get the font аrial.ttf unit height I have to do
Code: [Select]
k:=1.074/ftFont.SizeInPoints;
...
CoordInMyEditor.x:=k*_glyph^.outline.points^[j].x/64;
CoordInMyEditor.y:=k*_glyph^.outline.points^[j].y/64;
...
To get the times.ttf unit height I have to do
Code: [Select]
k:=1.162/ftFont.SizeInPoints;
...
CoordInMyEditor.x:=k*_glyph^.outline.points^[j].x/64;
CoordInMyEditor.y:=k*_glyph^.outline.points^[j].y/64;
...
Where did these factors and how to get them from TFreeTypeFont?

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #16 on: February 25, 2013, 12:45:44 am »
I'm not sure.

There are ascent and descent values, full height or not full height, etc.

full height = ascent + descent + bottom margin

Also values found in the font file may not be accurate.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #17 on: February 25, 2013, 08:59:06 am »
Ascent and Descend present in LazFreeType. What is bottom margin?

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #18 on: February 25, 2013, 11:56:22 am »
It is LineSpacing.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #19 on: February 25, 2013, 12:14:45 pm »
No. it not work((

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #20 on: February 25, 2013, 05:10:41 pm »
It's possible that the font "size in pixels" is not exactly the same as the size of the glyphs. This depends on how the font file was made.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #21 on: February 26, 2013, 06:14:41 am »
However in other applications these fonts are displayed correctly
« Last Edit: February 26, 2013, 06:21:10 am by zamtmn »

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #22 on: February 26, 2013, 11:38:30 am »
Maybe there are some tricks. I don't know.

Obviously, it is not possible to determine the size by computing the bounding rectangle of the glyphs, because some fonts have vertical overhang (like 'script' fonts).

Note that there are different values inside a font file that can be used, they might be contradictory or wrong. Maybe you can compare with FreeType dll rendering, and see if it is different. In this case, you can look at the code to see if there are some special tests added.
« Last Edit: February 26, 2013, 11:40:39 am by circular »
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #23 on: February 26, 2013, 12:18:21 pm »
Ok. I try to understand.
I made a small example (http://download.shamangrad.net/zcad/ttf2vector.7z). Need to get the character height SymbolH
Code: [Select]
const
     SymbolH=300;
In the example of an incorrect calculation of the coefficient for the map coordinates in TTF to range 0-SymbolH
Code: [Select]
     k:=(FTTFFont.Ascent+FTTFFont.Descent+FTTFFont.LineSpacing)/FTTFFont.SizeInPixels;
     k:=SymbolH*k/FTTFFont.SizeInPixels;

Archive contains the font arial.ttf

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #24 on: February 26, 2013, 11:32:22 pm »
Font ascent includes :
- small top margin
- space for accents
- letters up to baseline

So I suppose it's normal that you get some space above it.
« Last Edit: February 26, 2013, 11:39:08 pm by circular »
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #25 on: February 26, 2013, 11:47:10 pm »
I need the value CapHeight of your pictures. It is described in the "'OS/2' Table - OS/2 and Windows Metrics" http://www.microsoft.com/typography/otspec/os2.htm
OS/2 Table from arial.ttf
Quote
'OS/2' Table - OS/2 and Windows Metrics
---------------------------------------
Size = 96 bytes (expecting 96 bytes)
  'OS/2' version:           3
  xAvgCharWidth:            904
  usWeightClass:            400
  usWidthClass:             5
  fsType:                   0x0008
  ySubscriptXSize:          1434
  ySubscriptYSize:          1331
  ySubscriptXOffset:        0
  ySubscriptYOffset:        283
  ySuperscriptXSize:        1434
  ySuperscriptYSize:        1331
  ySuperscriptXOffset:      0
  ySuperscriptYOffset:      977
  yStrikeoutSize:           102
  yStrikeoutPosition:       530
  sFamilyClass:             8    subclass = 5
  PANOSE:                   2 11  6  4  2  2  2  2  2  4
  Unicode Range 1( Bits 0 - 31 ): E0002AFF
  Unicode Range 2( Bits 32- 63 ): C0007843
  Unicode Range 3( Bits 64- 95 ): 00000009
  Unicode Range 4( Bits 96-127 ): 00000000
  achVendID:                'TMC '
  fsSelection:              0x0040
  usFirstCharIndex:         0x0020
  usLastCharIndex:          0xFFFC
  sTypoAscender:            1491
  sTypoDescender:           -431
  sTypoLineGap:             307
  usWinAscent:              1854
  usWinDescent:             434
  CodePage Range 1( Bits 0 - 31 ): 400001FF
  CodePage Range 2( Bits 32- 63 ): FFFF0000
  sxHeight:                 1062
  sCapHeight:               1467 <-----------------------------------------------------------------------------------
  usDefaultChar:            0x0000
  usBreakChar:              0x0020
  usMaxLookups:             4
But in type TT_OS2 it not present((
« Last Edit: February 27, 2013, 02:34:44 am by zamtmn »

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #26 on: February 27, 2013, 09:50:25 am »
faced with a strange moment. I look at the contents of the arial.ttf:
Code: [Select]
'hhea' Table - Horizontal Header
--------------------------------
Size = 36 bytes (expecting 36 bytes)
'hhea' version:         1.0
yAscender:            1854<--------------------------------Ascend;
yDescender:           -434
yLineGap:             67
advanceWidthMax:      4096
minLeftSideBearing:   -1361
........................................
........................................
Symbol "T"
Glyph  55: off = 0x00004B08, len = 258
  numberOfContours: 1
  xMin: 48
  yMin: 0
  xMax: 1210
  yMax: 1466
.............
Coordinates
-----------
  0: Rel (   531,     0)  ->  Abs (   531,     0)
  1: Rel (     0,  1293)  ->  Abs (   531,  1293)
  2: Rel (  -483,     0)  ->  Abs (    48,  1293)
  3: Rel (     0,   173)  ->  Abs (    48,  1466)
  4: Rel (  1162,     0)  ->  Abs (  1210,  1466)
  5: Rel (     0,  -173)  ->  Abs (  1210,  1293)
  6: Rel (  -485,     0)  ->  Abs (   725,  1293)
  7: Rel (     0, -1293)  ->  Abs (   725,     0)
........................................
If I set the font size in the test program to 1854/64, I have to see the array coordinates such as a ttf. But it is not so
Code: [Select]
FTTFFont.SizeInPoints:=1854/64;
............................
_glyph^.outline.points^=
{
  {
    X = 514, Y = 0},
  {
    X = 514, Y = 1253},
  {
    X = 47, Y = 1253},
  {
    X = 47, Y = 1420},
  {
    X = 1172, Y = 1420},
  {
    X = 1172, Y = 1253},
  {
    X = 702, Y = 1253},
  {
    X = 702, Y = 0},
.........
}
Why they are a little less?

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #27 on: February 27, 2013, 10:36:22 am »
Maybe it includes rounded letters. See for example the letter C.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 640
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #28 on: February 27, 2013, 05:06:32 pm »
At last everything worked as it should! Require minor changes to EasyLazFreeType for CapHeight property. Please review the attached patch.

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: [Solved][LazFreeType]How to interpolate a point not on the curve?
« Reply #29 on: February 27, 2013, 05:26:11 pm »
Congratulations, that's perfect.

Patch seems good to me.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018