freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] ImageCache and SBitCache question


From: Memory, Richard
Subject: [ft] ImageCache and SBitCache question
Date: Thu, 21 Jul 2005 18:06:40 -0700

Hi,

I'm using both the Image and Sbit caches and I have 2 questions. For
reference purposes, I am using Freetype 2.1.10. Most likely I'm simply
using the APIs incorrectly.

1) Using FTC_SBitCache_Lookup(), I haven't been able to find a way to
control the "render mode" (In fact, I'm not sure I'm correctly
interpreting the value of the FTC_Sbit->format field returned from the
call to FTC_SBitCache_Lookup).

I'd like to set the render mode to FT_RENDER_MODE_MONO, but I can't see
where to do this. I've tried setting the imageType.flags =
FT_RENDER_MODE_MONO, but this doesn't seem to have any effect. Instead,
it looks like I'm getting a bitmap in the 8 bit FT_PIXEL_MODE_GRAY
format (the sbit->format field has a value of 2), but I'm not sure.

Is there a way to set the render mode when using FTC_SBitCache_Lookup()?

Here is my code snippet:

        imageType.face_id = (FTC_FaceID)&font;
        imageType.width = 16;
        imageType.height = 16;
        imageType.flags = FT_RENDER_MODE_MONO;

        if ((error = FTC_SBitCache_Lookup(sbitsCache, &imageType,
glyphIndex, &sbit, &node)) != 0)
            {
            printf("Error during sbit glyph lookup: 0x%x\n", error);
            return(error);
            }

2) Using FTC_ImageCache_Lookup(), I have not found a reliable way to
access the FT_GlyphSlotRec inside of the FT_FaceRec structure when I use
FTC_ImageCache_Lookup() API.

        glyphIndex = FTC_CMapCache_Lookup(cmapCache, (FTC_FaceID)&font,
0, myText[i]);

        if ((error = FTC_ImageCache_Lookup(imageCache, &imageType,
glyphIndex, &glyph, &node)) != 0)
            {
            printf("Error during image cache lookup: 0x%x\n", error);
            return(error);
            }

        if ((error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_MONO, 0,
0)) != 0)
            {
            printf("Error during glyph to bitmap conversion: 0x%x\n",
error);
            return(error);
            }

        glyphBitmap = (FT_BitmapGlyph)glyph;

        hBearingY = font.face->glyph->metrics.horiBearingY;   

The face is loaded by my "requester" function which isn't shown, but I'm
not sure the glyph is loaded into the "glyph slot" of the face when I
use FTC_ImageCache_Lookup(). 

Thanks,

Richard




reply via email to

[Prev in Thread] Current Thread [Next in Thread]