The bitmap stuff is working great. Case closed! Michael
On Wed, Sep 29, 2010 at 12:14 PM, Brady Duga <[email protected]> wrote: > Ah, I see. Yeah, I am pretty sure (though mainly from memory) that you can > get the descender that way. I think you can recreate all the per-glyph > metrics available from normal font loading using some combination of > advances, top/left, and the bitmap data *except* for lsb/rsb deltas, which > you can't really get using the cache. > > --Brady > > On Sep 29, 2010, at 11:28 AM, Michael Plitkins wrote: > >> Trust me, this is a very special case of character at a time rendering >> with some character tops or baselines aligned to neighboring glyph top >> edges, etc. as opposed to a run of text. If the bitmap height - top >> will get me a descender, then I am all done. >> >> Michael >> >> On Wed, Sep 29, 2010 at 11:12 AM, Brady Duga <[email protected]> wrote: >>> Again, I really don't think you want descenders per-glyph. So, say you want >>> to draw some text on a line. If we consider the upper-left of the screen to >>> be 0,0 with y increasing as we go down, and you want to draw a line whose >>> baseline is at y=100, then you: >>> >>> set x to 0 >>> set y to 100 >>> for every glyph: >>> get cached glyph info >>> draw bitmap at x+glyph.left, y - glyph.top >>> set x to x + glyph.advance.x >>> >>> This will place all your glyphs on the same baseline. If you really want to >>> know how much of the glyph extends below the line, then it is just the >>> bitmap height minus top. >>> >>> --Brady >>> >>> On Sep 29, 2010, at 11:04 AM, Michael Plitkins wrote: >>> >>>> Yes it does work, but there is still no way to get the descender. The >>>> FT_GlyphRec already has some of the FT_Glyph_Metrics information in >>>> the form of the advance. Why doesn't the FT_GlyphRec contain the >>>> remaining information? Memory concerns? Performance? >>>> >>>> Thanks again for help and suggestions. >>>> >>>> Michael >>>> >>>> On Wed, Sep 29, 2010 at 9:50 AM, Michael Plitkins >>>> <[email protected]> wrote: >>>>> Thanks. This may well get me moving forward. I do indeed need to >>>>> measure the horiBearingY because I am trying to line up type of >>>>> different sizes to get the presentation that we need. Measuring a few >>>>> sample characters will be adequate. Using the rendered bitmap still >>>>> won't give me a way to calculate the descender though (all I will know >>>>> is the actual full height of the rendered glyph). >>>>> >>>>> I knew that the FT_Load_Glyph(), was bogus, but it was my last ditch >>>>> attempt. >>>>> >>>>> Using FTC_CMapCache_Lookup() is on list my too. >>>>> >>>>> Many thanks and I will report how this turns out. >>>>> >>>>> Michael >>>>> >>>>> On Wed, Sep 29, 2010 at 8:34 AM, Brady Duga <[email protected]> wrote: >>>>>> Well, I am not entirely sure what you want to do. Using horiBearingY as >>>>>> the >>>>>> ascender seems weird - do you really want to use glyph metrics for line >>>>>> metrics? Or do you really need the ascender/descender info for every >>>>>> glyph? >>>>>> In any case, you shouldn't be calling FT_Load_Glyph when using the cache >>>>>> system. Instead, you let the cache subsytem make that call using the load >>>>>> flags you supply to FTC_ImageCache_LookupScaler(). That gives you an >>>>>> FT_Glyph which you can use for basic glyph metrics. Specifically the >>>>>> "advance" vector of that struct tells you how far to move to account for >>>>>> this glyph. In a more interesting case, you would pass FT_LOAD_RENDER to >>>>>> the >>>>>> cache subsystem, which should make the returned glyph be an >>>>>> FT_BitmapGlyph. >>>>>> That in turn gives you the left/top coordinates for the actual bitmap, >>>>>> plus >>>>>> an FT_Bitmap struct you can use for more information. Once you have the >>>>>> top >>>>>> and left values, you can essentially calculate the horibearingX/Y, though >>>>>> you may not need to bother. The nice thing about using the cache is, in >>>>>> most >>>>>> cases rendering is fast (already cached). It's only a problem if you >>>>>> plan to >>>>>> measure a *lot* of glyphs that you don't plan to render. Of course, in >>>>>> that >>>>>> case there isn't much point in using the cache at all. >>>>>> You might also want to consider caching the char map >>>>>> using FTC_CMapCache_Lookup instead of FT_Get_Char_Index. >>>>>> --Brady >>>>>> >>>>>> >>>>>> On Sep 28, 2010, at 11:30 PM, Werner LEMBERG wrote: >>>>>> >>>>>> Please help this guy. >>>>>> >>>>>> >>>>>> Werner >>>>>> >>>>>> From: Michael Plitkins <[email protected]> >>>>>> Date: September 28, 2010 9:50:48 PM PDT >>>>>> To: [email protected] >>>>>> Subject: freetype cache and glyph metrics >>>>>> >>>>>> >>>>>> Hello Werner, >>>>>> >>>>>> I have been using freetype for some time and have come to my first >>>>>> stumbling block: When using the image and font face caches, how can I >>>>>> get the the full metrics of a glyph (metrics.horiBearingY, etc.)? It >>>>>> seems that information is only available from the FT_GlyphSlotRec in >>>>>> the face itself. When using the cache APIs all of my attempts to get >>>>>> at the FT_Glyph_Metrics have yielded inconsistent results. Here is one >>>>>> of my latest attempts: >>>>>> >>>>>> void nlGfxContext :: GetGlyphMetrics(nlULONG aHeight, char aGlyph, >>>>>> nlFontMetrics *aOutMetrics) >>>>>> { >>>>>> if ((mFont != NULL) && (aOutMetrics != NULL)) >>>>>> { >>>>>> FT_Face font; >>>>>> FTC_ScalerRec scaler; >>>>>> >>>>>> scaler.face_id = mFont; >>>>>> scaler.width = 0; >>>>>> scaler.height = aHeight; >>>>>> scaler.pixel = 1; >>>>>> scaler.x_res = 0; >>>>>> scaler.y_res = 0; >>>>>> >>>>>> font = mGlobals->LookupFontID(mFont); >>>>>> >>>>>> if (font != NULL) >>>>>> { >>>>>> FTC_ImageCache icache = mGlobals->GetFontImageCache(); >>>>>> FT_Glyph glyph; >>>>>> FTC_Node node; >>>>>> FT_UInt charidx = FT_Get_Char_Index(font, aGlyph); >>>>>> FT_Error err; >>>>>> >>>>>> err = FTC_ImageCache_LookupScaler(icache, &scaler, >>>>>> FT_LOAD_DEFAULT, charidx, &glyph, &node); >>>>>> >>>>>> FT_Load_Glyph(font, charidx, FT_LOAD_DEFAULT); >>>>>> >>>>>> if (err == FT_Err_Ok) >>>>>> { >>>>>> aOutMetrics->mHeight = font->glyph->metrics.height >> 6; >>>>>> aOutMetrics->mAscender = >>>>>> font->glyph->metrics.horiBearingY >> >>>>>> 6; >>>>>> aOutMetrics->mDescender = -(aOutMetrics->mHeight - >>>>>> aOutMetrics->mAscender); >>>>>> aOutMetrics->mMaxAdvance = >>>>>> font->glyph->metrics.horiAdvance >> 6; >>>>>> >>>>>> FTC_Node_Unref(node, mGlobals->GetFontCacheManager()); >>>>>> } >>>>>> } >>>>>> } >>>>>> } >>>>>> >>>>>> This is my horrible attempt to use the image cache scaler to get the >>>>>> glyph that i want at the size that i want and somehow get the glyph >>>>>> metrics to be set as i want as part of the FT_Load_Glyph(). It seems >>>>>> like it shouldn't work and it doesn't. >>>>>> >>>>>> How does one get the metrics for an individual glyph and use the >>>>>> caching subsystems at the same time? >>>>>> >>>>>> I apologize in advance if this has been answered somewhere out on the >>>>>> internet, but I was unable to find it. >>>>>> >>>>>> Many thanks. >>>>>> >>>>>> Michael Plitkins >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Freetype mailing list >>>>>> [email protected] >>>>>> http://lists.nongnu.org/mailman/listinfo/freetype >>>>>> >>>>>> >>>>> >>> >>> > > _______________________________________________ Freetype mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/freetype
