Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HybridOS
hiSVG
Commits
2b23da97
Commit
2b23da97
authored
May 10, 2021
by
XueShuming
Browse files
add code for destroy text_context
parent
81519ade
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/hisvg-text-helper.h
View file @
2b23da97
...
...
@@ -179,11 +179,13 @@ typedef struct _HiSVGTextRectangle {
}
HiSVGTextRectangle
;
HiSVGTextContext
*
hisvg_text_context_create
(
double
dpi
,
const
char
*
language
,
HiSVGTextDirection
*
direction
,
HiSVGTextGravity
*
gravity
);
void
hisvg_text_context_destroy
(
HiSVGTextContext
*
context
);
HiSVGTextGravity
hisvg_text_context_get_gravity
(
HiSVGTextContext
*
context
);
HiSVGTextContextLayout
*
hisvg_text_context_layout_create
(
HiSVGTextContext
*
context
,
int
letter_spacing
,
HiSVGTextAlignment
alignment
,
const
HiSVGFontDescription
*
desc
,
int
font_decoration
,
const
char
*
text
);
void
hisvg_text_context_layout_destroy
(
HiSVGTextContextLayout
*
layout
);
void
hisvg_text_context_layout_get_size
(
HiSVGTextContextLayout
*
layout
,
int
*
width
,
int
*
height
);
HiSVGTextContext
*
hisvg_text_layout_get_context
(
HiSVGTextContextLayout
*
layout
);
...
...
@@ -195,7 +197,7 @@ HiSVGFontDescription* hisvg_font_description_create (const char* type,
HiSVGTextWeight
weight
,
HiSVGTextStretch
stretch
,
gint
size
,
guint
size_is_absolute
);
void
hisvg_font_description_
free
(
HiSVGFontDescription
*
desc
);
void
hisvg_font_description_
destroy
(
HiSVGFontDescription
*
desc
);
double
hisvg_text_gravity_to_rotation
(
HiSVGTextGravity
gravity
);
...
...
src/hisvg-text-helper.c
View file @
2b23da97
...
...
@@ -68,6 +68,12 @@ HiSVGTextContext* hisvg_text_context_create (double dpi, const char* language, H
return
ctx
;
}
void
hisvg_text_context_destroy
(
HiSVGTextContext
*
context
)
{
g_object_unref
(
context
->
pango_ctx
);
free
(
context
);
}
HiSVGTextGravity
hisvg_text_context_get_gravity
(
HiSVGTextContext
*
context
)
{
return
pango_context_get_gravity
(
context
->
pango_ctx
);
...
...
@@ -129,6 +135,12 @@ HiSVGTextContextLayout* hisvg_text_context_layout_create (HiSVGTextContext* cont
return
result
;
}
void
hisvg_text_context_layout_destroy
(
HiSVGTextContextLayout
*
layout
)
{
g_object_unref
(
layout
->
pango_layout
);
free
(
layout
);
}
void
hisvg_text_context_layout_get_size
(
HiSVGTextContextLayout
*
layout
,
int
*
width
,
int
*
height
)
{
pango_layout_get_size
(
layout
->
pango_layout
,
width
,
height
);
...
...
@@ -157,7 +169,7 @@ HiSVGFontDescription* hisvg_font_description_create (const char* type,
return
desc
;
}
void
hisvg_font_description_
free
(
HiSVGFontDescription
*
desc
)
void
hisvg_font_description_
destroy
(
HiSVGFontDescription
*
desc
)
{
free
(
desc
->
type
);
free
(
desc
->
family
);
...
...
@@ -192,7 +204,18 @@ void hisvg_text_context_layout_get_extents (HiSVGTextContextLayout* layout, HiSV
double
hisvg_text_gravity_to_rotation
(
HiSVGTextGravity
gravity
)
{
return
pango_gravity_to_rotation
(
gravity
);
double
rotation
;
switch
(
gravity
)
{
default:
case
HISVG_TEXT_GRAVITY_AUTO
:
/* shut gcc up */
case
HISVG_TEXT_GRAVITY_SOUTH
:
rotation
=
0
;
break
;
case
HISVG_TEXT_GRAVITY_NORTH
:
rotation
=
G_PI
;
break
;
case
HISVG_TEXT_GRAVITY_EAST
:
rotation
=
-
G_PI_2
;
break
;
case
HISVG_TEXT_GRAVITY_WEST
:
rotation
=
+
G_PI_2
;
break
;
}
return
rotation
;
}
void
hisvg_cairo_update_text_context
(
cairo_t
*
cr
,
HiSVGTextContext
*
context
)
...
...
src/hisvg-text.c
View file @
2b23da97
...
...
@@ -533,7 +533,7 @@ struct _HiSVGTextLayout {
static
void
hisvg_text_layout_free
(
HiSVGTextLayout
*
layout
)
{
g_object_unref
(
layout
->
layout
);
hisvg_text_context_layout_destroy
(
layout
->
layout
);
g_free
(
layout
);
}
...
...
@@ -558,7 +558,7 @@ hisvg_text_create_layout (HiSVGDrawingCtx * ctx,
layout
=
hisvg_text_context_layout_create
(
context
,
letter_spacing
,
alignment
,
font_desc
,
state
->
font_decor
,
text
);
hisvg_font_description_
free
(
font_desc
);
hisvg_font_description_
destroy
(
font_desc
);
return
layout
;
}
...
...
@@ -618,8 +618,8 @@ hisvg_text_render_text (HiSVGDrawingCtx * ctx, const char *text, gdouble * x, gd
else
*
x
+=
w
/
(
double
)
HISVG_TEXT_SCALE
;
g_object_unref
(
layout
);
g_object_unref
(
context
);
hisvg_text_context_layout_destroy
(
layout
);
hisvg_text_context_destroy
(
context
);
}
static
gdouble
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment