forked from old/legacy-imlib2
parent
b9c591d390
commit
275d89b1d9
|
@ -3105,50 +3105,59 @@ imlib_free_font(void)
|
|||
ctx->font = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param font A previously loaded font.
|
||||
* @param fallback_font A previously loaded font to be chained to the given font.
|
||||
* @return 0 on success.
|
||||
*
|
||||
* This arranges for the given fallback font to be used if a glyph does not exist in the given font when text is being rendered.
|
||||
* Fonts can be arranged in an aribitrarily long chain and attempts will be made in order on the chain.
|
||||
* Cycles in the chain are not possible since the given fallback font is removed from any chain it's already in.
|
||||
* A fallback font may be a member of only one chain. Adding it as the fallback font to another font will remove it from it's first fallback chain.
|
||||
* This arranges for the given fallback font to be used if a glyph does not
|
||||
* exist in the given font when text is being rendered.
|
||||
* Fonts can be arranged in an aribitrarily long chain and attempts will be
|
||||
* made in order on the chain.
|
||||
* Cycles in the chain are not possible since the given fallback font is
|
||||
* removed from any chain it's already in.
|
||||
* A fallback font may be a member of only one chain. Adding it as the
|
||||
* fallback font to another font will remove it from it's first fallback chain.
|
||||
**/
|
||||
EAPI int
|
||||
imlib_insert_font_into_fallback_chain(Imlib_Font font, Imlib_Font fallback_font)
|
||||
{
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_insert_font_into_fallback_chain", "font", font, 1);
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_insert_font_into_fallback_chain", "fallback_font", fallback_font, 1);
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_insert_font_into_fallback_chain",
|
||||
"font", font, 1);
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_insert_font_into_fallback_chain",
|
||||
"fallback_font", fallback_font, 1);
|
||||
return imlib_insert_font_into_fallback_chain_imp(font, fallback_font);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fallback_font A font previously added to a fallback chain
|
||||
* @param fallback_font A font previously added to a fallback chain.
|
||||
* @return 0 on success.
|
||||
*
|
||||
* This removes the given font from any fallback chain it may be in.
|
||||
* Removing this font joins its previous and next font together in the fallback chain.
|
||||
* Removing this font joins its previous and next font together in the fallback
|
||||
* chain.
|
||||
**/
|
||||
EAPI void
|
||||
imlib_remove_font_from_fallback_chain(Imlib_Font fallback_font)
|
||||
{
|
||||
CHECK_PARAM_POINTER("imlib_remove_font_from_fallback_chain", "fallback_font", fallback_font);
|
||||
CHECK_PARAM_POINTER("imlib_remove_font_from_fallback_chain",
|
||||
"fallback_font", fallback_font);
|
||||
imlib_remove_font_from_fallback_chain_imp(fallback_font);
|
||||
}
|
||||
|
||||
EAPI Imlib_Font
|
||||
imlib_get_prev_font_in_fallback_chain(Imlib_Font fn)
|
||||
{
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_get_prev_font_in_fallback_chain", "fn", fn, 0);
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_get_prev_font_in_fallback_chain",
|
||||
"fn", fn, 0);
|
||||
return ((ImlibFont *) fn)->fallback_prev;
|
||||
}
|
||||
|
||||
EAPI Imlib_Font
|
||||
imlib_get_next_font_in_fallback_chain(Imlib_Font fn)
|
||||
{
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_get_next_font_in_fallback_chain", "fn", fn, 0);
|
||||
CHECK_PARAM_POINTER_RETURN("imlib_get_next_font_in_fallback_chain",
|
||||
"fn", fn, 0);
|
||||
return ((ImlibFont *) fn)->fallback_next;
|
||||
}
|
||||
|
||||
|
|
|
@ -246,17 +246,21 @@ imlib_render_str(ImlibImage * im, ImlibFont * fn, int drx, int dry,
|
|||
}
|
||||
|
||||
/*
|
||||
* This function returns the first font in the fallback chain to contain the requested glyph.
|
||||
* This function returns the first font in the fallback chain to contain
|
||||
* the requested glyph.
|
||||
* The glyph index is returned in ret_index
|
||||
* If the glyph is not found, then the given font pointer is returned and ret_index will be set to 0
|
||||
* If the glyph is not found, then the given font pointer is returned and
|
||||
* ret_index will be set to 0
|
||||
*/
|
||||
ImlibFont *
|
||||
imlib_find_glyph_in_font_chain(ImlibFont * first_fn, int gl, int *ret_index)
|
||||
{
|
||||
ImlibFont *fn = first_fn;
|
||||
|
||||
do
|
||||
{
|
||||
int index = FT_Get_Char_Index(fn->ft.face, gl);
|
||||
|
||||
if (index <= 0)
|
||||
fn = fn->fallback_next;
|
||||
else
|
||||
|
@ -264,7 +268,8 @@ imlib_find_glyph_in_font_chain(ImlibFont * first_fn, int gl, int *ret_index)
|
|||
(*ret_index) = index;
|
||||
return fn;
|
||||
}
|
||||
} while(fn);
|
||||
}
|
||||
while (fn);
|
||||
|
||||
(*ret_index) = 0;
|
||||
return first_fn;
|
||||
|
@ -347,8 +352,8 @@ imlib_font_draw(ImlibImage * dst, DATA32 col, ImlibFont * fn, int x, int y,
|
|||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index, ft_kerning_default,
|
||||
&delta);
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = imlib_font_cache_glyph_get(fn_in_chain, index);
|
||||
|
|
|
@ -215,6 +215,7 @@ imlib_insert_font_into_fallback_chain_imp(ImlibFont * fn, ImlibFont *fallback)
|
|||
|
||||
/* insert fallback into fn's font chain */
|
||||
ImlibFont *tmp = fn->fallback_next;
|
||||
|
||||
fn->fallback_next = fallback;
|
||||
fallback->fallback_prev = fn;
|
||||
fallback->fallback_next = tmp;
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
#include "rgbadraw.h"
|
||||
#include "rotate.h"
|
||||
|
||||
extern ImlibFont *
|
||||
imlib_find_glyph_in_font_chain(ImlibFont * first_fn, int gl, int *ret_index); /* defined in font_draw.c */
|
||||
extern ImlibFont *imlib_find_glyph_in_font_chain(ImlibFont * first_fn, int gl, int *ret_index); /* defined in font_draw.c */
|
||||
|
||||
extern FT_Library ft_lib;
|
||||
|
||||
|
@ -52,8 +51,8 @@ imlib_font_query_size(ImlibFont * fn, const char *text, int *w, int *h)
|
|||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index, ft_kerning_default,
|
||||
&delta);
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = imlib_font_cache_glyph_get(fn_in_chain, index);
|
||||
|
@ -133,8 +132,8 @@ imlib_font_query_advance(ImlibFont * fn, const char *text, int *h_adv,
|
|||
{
|
||||
FT_Vector delta;
|
||||
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index, ft_kerning_default,
|
||||
&delta);
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
pen_x += delta.x << 2;
|
||||
}
|
||||
fg = imlib_font_cache_glyph_get(fn_in_chain, index);
|
||||
|
@ -191,8 +190,8 @@ imlib_font_query_char_coords(ImlibFont * fn, const char *text, int pos,
|
|||
kern = 0;
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index, ft_kerning_default,
|
||||
&delta);
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
kern = delta.x << 2;
|
||||
pen_x += kern;
|
||||
}
|
||||
|
@ -274,8 +273,8 @@ imlib_font_query_text_at_pos(ImlibFont * fn, const char *text, int x, int y,
|
|||
kern = 0;
|
||||
if ((use_kerning) && (prev_index) && (index))
|
||||
{
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index, ft_kerning_default,
|
||||
&delta);
|
||||
FT_Get_Kerning(fn_in_chain->ft.face, prev_index, index,
|
||||
ft_kerning_default, &delta);
|
||||
kern = delta.x << 2;
|
||||
pen_x += kern;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue