|
From: <br...@us...> - 2010-05-02 04:58:09
|
Revision: 4134
http://openvrml.svn.sourceforge.net/openvrml/?rev=4134&view=rev
Author: braden
Date: 2010-05-02 04:58:00 +0000 (Sun, 02 May 2010)
Log Message:
-----------
Refactor some of the Text node rendering logic. Also, apply FT_Done_Glyph (so we shouldn't be leaking those anymore).
Modified Paths:
--------------
branches/0.18/ChangeLog
branches/0.18/src/node/vrml97/text.cpp
Property Changed:
----------------
branches/0.18/
branches/0.18/src/libopenvrml/openvrml/bad_url.cpp
branches/0.18/src/libopenvrml/openvrml/bad_url.h
branches/0.18/src/libopenvrml/openvrml/local/proto.cpp
branches/0.18/src/libopenvrml/openvrml/local/proto.h
branches/0.18/src/libopenvrml/openvrml/scene.cpp
branches/0.18/src/libopenvrml/openvrml/scene.h
branches/0.18/src/libopenvrml/openvrml/script.cpp
branches/0.18/src/mozilla-plugin/
branches/0.18/src/node/vrml97/register_node_metatypes.cpp
branches/0.18/src/node/x3d-cad-geometry/cad_face.cpp
branches/0.18/src/node/x3d-cad-geometry/cad_face.h
branches/0.18/src/node/x3d-cad-geometry/indexed_quad_set.cpp
branches/0.18/src/node/x3d-cad-geometry/indexed_quad_set.h
branches/0.18/src/node/x3d-cad-geometry/register_node_metatypes.cpp
branches/0.18/src/node/x3d-core/metadata_double.cpp
branches/0.18/src/node/x3d-core/metadata_double.h
branches/0.18/src/node/x3d-core/metadata_float.cpp
branches/0.18/src/node/x3d-core/metadata_float.h
branches/0.18/src/node/x3d-core/metadata_integer.cpp
branches/0.18/src/node/x3d-core/metadata_integer.h
branches/0.18/src/node/x3d-core/metadata_set.cpp
branches/0.18/src/node/x3d-core/metadata_set.h
branches/0.18/src/node/x3d-core/metadata_string.cpp
branches/0.18/src/node/x3d-core/metadata_string.h
branches/0.18/src/node/x3d-core/register_node_metatypes.cpp
branches/0.18/src/node/x3d-dis/espdu_transform.cpp
branches/0.18/src/node/x3d-dis/espdu_transform.h
branches/0.18/src/node/x3d-dis/receiver_pdu.cpp
branches/0.18/src/node/x3d-dis/receiver_pdu.h
branches/0.18/src/node/x3d-dis/register_node_metatypes.cpp
branches/0.18/src/node/x3d-dis/signal_pdu.cpp
branches/0.18/src/node/x3d-dis/signal_pdu.h
branches/0.18/src/node/x3d-dis/transmitter_pdu.cpp
branches/0.18/src/node/x3d-dis/transmitter_pdu.h
branches/0.18/src/node/x3d-environmental-effects/register_node_metatypes.cpp
branches/0.18/src/node/x3d-environmental-effects/texture_background.cpp
branches/0.18/src/node/x3d-environmental-effects/texture_background.h
branches/0.18/src/node/x3d-event-utilities/boolean_filter.cpp
branches/0.18/src/node/x3d-event-utilities/boolean_filter.h
branches/0.18/src/node/x3d-event-utilities/boolean_sequencer.cpp
branches/0.18/src/node/x3d-event-utilities/boolean_sequencer.h
branches/0.18/src/node/x3d-event-utilities/boolean_toggle.cpp
branches/0.18/src/node/x3d-event-utilities/boolean_toggle.h
branches/0.18/src/node/x3d-event-utilities/boolean_trigger.cpp
branches/0.18/src/node/x3d-event-utilities/boolean_trigger.h
branches/0.18/src/node/x3d-event-utilities/integer_sequencer.cpp
branches/0.18/src/node/x3d-event-utilities/integer_sequencer.h
branches/0.18/src/node/x3d-event-utilities/integer_trigger.cpp
branches/0.18/src/node/x3d-event-utilities/integer_trigger.h
branches/0.18/src/node/x3d-event-utilities/register_node_metatypes.cpp
branches/0.18/src/node/x3d-event-utilities/time_trigger.cpp
branches/0.18/src/node/x3d-event-utilities/time_trigger.h
branches/0.18/src/node/x3d-geometry2d/arc2d.cpp
branches/0.18/src/node/x3d-geometry2d/arc2d.h
branches/0.18/src/node/x3d-geometry2d/arc_close2d.cpp
branches/0.18/src/node/x3d-geometry2d/arc_close2d.h
branches/0.18/src/node/x3d-geometry2d/circle2d.cpp
branches/0.18/src/node/x3d-geometry2d/circle2d.h
branches/0.18/src/node/x3d-geometry2d/disk2d.cpp
branches/0.18/src/node/x3d-geometry2d/disk2d.h
branches/0.18/src/node/x3d-geometry2d/polyline2d.cpp
branches/0.18/src/node/x3d-geometry2d/polyline2d.h
branches/0.18/src/node/x3d-geometry2d/polypoint2d.cpp
branches/0.18/src/node/x3d-geometry2d/polypoint2d.h
branches/0.18/src/node/x3d-geometry2d/rectangle2d.cpp
branches/0.18/src/node/x3d-geometry2d/rectangle2d.h
branches/0.18/src/node/x3d-geometry2d/register_node_metatypes.cpp
branches/0.18/src/node/x3d-geometry2d/triangle_set2d.cpp
branches/0.18/src/node/x3d-geometry2d/triangle_set2d.h
branches/0.18/src/node/x3d-geospatial/geo_coordinate.cpp
branches/0.18/src/node/x3d-geospatial/geo_coordinate.h
branches/0.18/src/node/x3d-geospatial/geo_elevation_grid.cpp
branches/0.18/src/node/x3d-geospatial/geo_elevation_grid.h
branches/0.18/src/node/x3d-geospatial/geo_location.cpp
branches/0.18/src/node/x3d-geospatial/geo_location.h
branches/0.18/src/node/x3d-geospatial/geo_lod.cpp
branches/0.18/src/node/x3d-geospatial/geo_lod.h
branches/0.18/src/node/x3d-geospatial/geo_metadata.cpp
branches/0.18/src/node/x3d-geospatial/geo_metadata.h
branches/0.18/src/node/x3d-geospatial/geo_origin.cpp
branches/0.18/src/node/x3d-geospatial/geo_origin.h
branches/0.18/src/node/x3d-geospatial/geo_position_interpolator.cpp
branches/0.18/src/node/x3d-geospatial/geo_position_interpolator.h
branches/0.18/src/node/x3d-geospatial/geo_touch_sensor.cpp
branches/0.18/src/node/x3d-geospatial/geo_touch_sensor.h
branches/0.18/src/node/x3d-geospatial/geo_viewpoint.cpp
branches/0.18/src/node/x3d-geospatial/geo_viewpoint.h
branches/0.18/src/node/x3d-geospatial/register_node_metatypes.cpp
branches/0.18/src/node/x3d-grouping/register_node_metatypes.cpp
branches/0.18/src/node/x3d-grouping/static_group.cpp
branches/0.18/src/node/x3d-grouping/static_group.h
branches/0.18/src/node/x3d-h-anim/h_anim_displacer.cpp
branches/0.18/src/node/x3d-h-anim/h_anim_displacer.h
branches/0.18/src/node/x3d-h-anim/h_anim_humanoid.cpp
branches/0.18/src/node/x3d-h-anim/h_anim_humanoid.h
branches/0.18/src/node/x3d-h-anim/h_anim_joint.cpp
branches/0.18/src/node/x3d-h-anim/h_anim_joint.h
branches/0.18/src/node/x3d-h-anim/h_anim_segment.cpp
branches/0.18/src/node/x3d-h-anim/h_anim_segment.h
branches/0.18/src/node/x3d-h-anim/h_anim_site.cpp
branches/0.18/src/node/x3d-h-anim/h_anim_site.h
branches/0.18/src/node/x3d-h-anim/register_node_metatypes.cpp
branches/0.18/src/node/x3d-interpolation/coordinate_interpolator2d.cpp
branches/0.18/src/node/x3d-interpolation/coordinate_interpolator2d.h
branches/0.18/src/node/x3d-interpolation/position_interpolator2d.cpp
branches/0.18/src/node/x3d-interpolation/position_interpolator2d.h
branches/0.18/src/node/x3d-interpolation/register_node_metatypes.cpp
branches/0.18/src/node/x3d-key-device-sensor/key_sensor.cpp
branches/0.18/src/node/x3d-key-device-sensor/key_sensor.h
branches/0.18/src/node/x3d-key-device-sensor/register_node_metatypes.cpp
branches/0.18/src/node/x3d-key-device-sensor/string_sensor.cpp
branches/0.18/src/node/x3d-key-device-sensor/string_sensor.h
branches/0.18/src/node/x3d-networking/load_sensor.cpp
branches/0.18/src/node/x3d-networking/load_sensor.h
branches/0.18/src/node/x3d-networking/register_node_metatypes.cpp
branches/0.18/src/node/x3d-nurbs/contour2d.cpp
branches/0.18/src/node/x3d-nurbs/contour2d.h
branches/0.18/src/node/x3d-nurbs/contour_polyline2d.cpp
branches/0.18/src/node/x3d-nurbs/contour_polyline2d.h
branches/0.18/src/node/x3d-nurbs/coordinate_double.cpp
branches/0.18/src/node/x3d-nurbs/coordinate_double.h
branches/0.18/src/node/x3d-nurbs/nurbs_curve.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_curve.h
branches/0.18/src/node/x3d-nurbs/nurbs_curve2d.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_curve2d.h
branches/0.18/src/node/x3d-nurbs/nurbs_orientation_interpolator.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_orientation_interpolator.h
branches/0.18/src/node/x3d-nurbs/nurbs_patch_surface.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_patch_surface.h
branches/0.18/src/node/x3d-nurbs/nurbs_position_interpolator.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_position_interpolator.h
branches/0.18/src/node/x3d-nurbs/nurbs_set.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_set.h
branches/0.18/src/node/x3d-nurbs/nurbs_surface_interpolator.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_surface_interpolator.h
branches/0.18/src/node/x3d-nurbs/nurbs_swept_surface.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_swept_surface.h
branches/0.18/src/node/x3d-nurbs/nurbs_swung_surface.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_swung_surface.h
branches/0.18/src/node/x3d-nurbs/nurbs_texture_coordinate.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_texture_coordinate.h
branches/0.18/src/node/x3d-nurbs/nurbs_trimmed_surface.cpp
branches/0.18/src/node/x3d-nurbs/nurbs_trimmed_surface.h
branches/0.18/src/node/x3d-nurbs/register_node_metatypes.cpp
branches/0.18/src/node/x3d-rendering/color_rgba.cpp
branches/0.18/src/node/x3d-rendering/color_rgba.h
branches/0.18/src/node/x3d-rendering/indexed_triangle_fan_set.cpp
branches/0.18/src/node/x3d-rendering/indexed_triangle_fan_set.h
branches/0.18/src/node/x3d-rendering/indexed_triangle_set.cpp
branches/0.18/src/node/x3d-rendering/indexed_triangle_set.h
branches/0.18/src/node/x3d-rendering/indexed_triangle_strip_set.cpp
branches/0.18/src/node/x3d-rendering/indexed_triangle_strip_set.h
branches/0.18/src/node/x3d-rendering/register_node_metatypes.cpp
branches/0.18/src/node/x3d-rendering/triangle_fan_set.cpp
branches/0.18/src/node/x3d-rendering/triangle_fan_set.h
branches/0.18/src/node/x3d-rendering/triangle_set.cpp
branches/0.18/src/node/x3d-rendering/triangle_set.h
branches/0.18/src/node/x3d-rendering/triangle_strip_set.cpp
branches/0.18/src/node/x3d-rendering/triangle_strip_set.h
branches/0.18/src/node/x3d-shape/fill_properties.cpp
branches/0.18/src/node/x3d-shape/fill_properties.h
branches/0.18/src/node/x3d-shape/line_properties.cpp
branches/0.18/src/node/x3d-shape/line_properties.h
branches/0.18/src/node/x3d-shape/register_node_metatypes.cpp
branches/0.18/src/node/x3d-texturing/multi_texture.cpp
branches/0.18/src/node/x3d-texturing/multi_texture.h
branches/0.18/src/node/x3d-texturing/multi_texture_coordinate.cpp
branches/0.18/src/node/x3d-texturing/multi_texture_coordinate.h
branches/0.18/src/node/x3d-texturing/multi_texture_transform.cpp
branches/0.18/src/node/x3d-texturing/multi_texture_transform.h
branches/0.18/src/node/x3d-texturing/register_node_metatypes.cpp
branches/0.18/src/node/x3d-texturing/texture_coordinate_generator.cpp
branches/0.18/src/node/x3d-texturing/texture_coordinate_generator.h
Property changes on: branches/0.18
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/local:3677-3689
/branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801
/trunk:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/local:3677-3689
/branches/node-modules:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688,3736-3801
/trunk:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Modified: branches/0.18/ChangeLog
===================================================================
--- branches/0.18/ChangeLog 2010-05-02 04:12:54 UTC (rev 4133)
+++ branches/0.18/ChangeLog 2010-05-02 04:58:00 UTC (rev 4134)
@@ -1,3 +1,54 @@
+2010-05-01 Braden McDaniel <br...@en...>
+
+ Refactor some of the Text node rendering logic. Also, apply
+ FT_Done_Glyph (so we shouldn't be leaking those anymore).
+
+ * src/node/vrml97/text.cpp
+ (text_node::line_geometry): Added class.
+ (text_node::glyph_geometry::glyph_geometry(FT_Face, FT_UInt,
+ float)): Construct glyph_geometry from a FT_Face, the glyph_index,
+ and the desired size. This constructor now does quite a bit of
+ heavy lifting: it loads the FT_Glyph, generates polygons from it,
+ and ultimately unloads it. The latter bit (unloading) is the only
+ real functional change here, as we were neglecting to do that
+ previously (and thus leaking). Previously, this logic lived in
+ text_node::update_geometry.
+ (text_node::glyph_geometry::coord() const): Added accessor to get
+ the coordinates.
+ (text_node::glyph_geometry::coord_index() const): Added accessor
+ to get the coordinate indices.
+ (text_node::glyph_geometry::advance_width() const): Added accessor
+ to get the advance_width.
+ (text_node::glyph_geometry::advance_height() const): Added
+ accessor to get the advance_height.
+ (text_node::line_geometry::line_geometry(bool, bool, bool)):
+ Construct the line_geometry.
+ (text_node::line_geometry::coord() const): Accessor to get the
+ coordinates.
+ (text_node::line_geometry::coord() const): Accessor to get the
+ coordinate indices.
+ (text_node::line_geometry::x_min() const): Accessor to get the
+ minimum x extent.
+ (text_node::line_geometry::x_max() const): Accessor to get the
+ maximum x extent.
+ (text_node::line_geometry::y_min() const): Accessor to get the
+ minimum y extent.
+ (text_node::line_geometry::y_max() const): Accessor to get the
+ maximum y extent.
+ (text_node::line_geometry::polygons() const): Accessor to get the
+ number of polygons.
+ (text_node::line_geometry::add(const glyph_geometry &)): Add
+ geometry for a glyph to the line. Previously, this logic lived in
+ text_node::update_geometry.
+ (text_node::line_geometry::scale(float)): Scale the line geometry
+ to a length.
+ (text_node::~text_node()): Assert that this->face is 0.
+ (text_node::do_shutdown(double)): Set this->face to 0 after it is
+ unloaded.
+ (text_node::update_geometry()): Moved logic to load the FT_Glyph
+ and generate polygons to the glyph_geometry constructor. Moved
+ logic to add glyph geometry to a line to line_geometry::add.
+
2010-04-28 Braden McDaniel <br...@en...>
* src/libopenvrml/openvrml/browser.cpp
Property changes on: branches/0.18/src/libopenvrml/openvrml/bad_url.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/bad_url.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17/src/libopenvrml/openvrml/bad_url.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/bad_url.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/bad_url.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/bad_url.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/node-modules/src/libopenvrml/openvrml/bad_url.h:3736-3801
/branches/node-modules/src/libopenvrml/openvrml/browser.h:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674
/trunk/src/libopenvrml/openvrml/bad_url.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/node-modules/src/libopenvrml/openvrml/bad_url.h:3736-3801
/branches/node-modules/src/libopenvrml/openvrml/browser.h:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674
/trunk/src/libopenvrml/openvrml/bad_url.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/local/proto.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/local/src/libopenvrml/openvrml/browser.cpp:3677-3689
/branches/node-modules/src/libopenvrml/openvrml/browser.cpp:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688
/branches/node-modules/src/libopenvrml/openvrml/local/proto.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/local/proto.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/local/src/libopenvrml/openvrml/browser.cpp:3677-3689
/branches/node-modules/src/libopenvrml/openvrml/browser.cpp:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688
/branches/node-modules/src/libopenvrml/openvrml/local/proto.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/local/proto.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/local/proto.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/local/src/libopenvrml/openvrml/browser.cpp:3677-3689
/branches/node-modules/src/libopenvrml/openvrml/browser.cpp:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688
/branches/node-modules/src/libopenvrml/openvrml/local/proto.h:3736-3801
/trunk/src/libopenvrml/openvrml/local/proto.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/local/src/libopenvrml/openvrml/browser.cpp:3677-3689
/branches/node-modules/src/libopenvrml/openvrml/browser.cpp:3622-3623,3632-3635,3637-3638,3640-3641,3643-3644,3646-3647,3649-3650,3654-3655,3657-3658,3661-3662,3664-3665,3667-3668,3670-3671,3673-3674,3684-3685,3687-3688
/branches/node-modules/src/libopenvrml/openvrml/local/proto.h:3736-3801
/trunk/src/libopenvrml/openvrml/local/proto.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/scene.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/scene.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17/src/libopenvrml/openvrml/scene.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/scene.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/scene.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/scene.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801
/trunk/src/libopenvrml/openvrml/scene.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17/src/libopenvrml/openvrml/scene.h:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/scene.h:3736-3801
/trunk/src/libopenvrml/openvrml/scene.h:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/libopenvrml/openvrml/script.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/script.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17/src/libopenvrml/openvrml/script.cpp:3713,3717,3719,3721,3725,3730,3732,3743,3746,3748,3750,3752,3754,3757,3759-3760,3764,3766,3824,3828,3836
/branches/node-modules/src/libopenvrml/openvrml/script.cpp:3736-3801
/trunk/src/libopenvrml/openvrml/script.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/mozilla-plugin
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/src/mozilla-plugin:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /trunk/src/mozilla-plugin:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Property changes on: branches/0.18/src/node/vrml97/register_node_metatypes.cpp
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/0.17/src/libopenvrml/openvrml/vrml97node.cpp:3713,3717,3719,3721,3725,3730,3732
/branches/local/src/libopenvrml/openvrml/vrml97node.cpp:3677-3689
/trunk/src/libopenvrml/openvrml/vrml97node.cpp:3401-3734
/trunk/src/node/vrml97/register_node_metatypes.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131
+ /branches/0.17/src/libopenvrml/openvrml/vrml97node.cpp:3713,3717,3719,3721,3725,3730,3732
/branches/local/src/libopenvrml/openvrml/vrml97node.cpp:3677-3689
/trunk/src/libopenvrml/openvrml/vrml97node.cpp:3401-3734
/trunk/src/node/vrml97/register_node_metatypes.cpp:3958,3965,3967,3969,3971,3973,3975-3976,3979,3981,3983,3985,3987,3989,3991,3997,3999,4001,4003,4005,4011,4013-4014,4017,4019,4021,4024,4026,4028,4030,4032,4041,4043,4045,4053,4055,4057,4059,4061,4063,4065,4067,4069,4071,4073,4075,4077,4079,4081,4083,4085,4087,4089,4091,4093,4095,4097,4099,4101,4108,4113,4115,4117,4119-4120,4122,4124,4129,4131,4133
Modified: branches/0.18/src/node/vrml97/text.cpp
===================================================================
--- branches/0.18/src/node/vrml97/text.cpp 2010-05-02 04:12:54 UTC (rev 4133)
+++ branches/0.18/src/node/vrml97/text.cpp 2010-05-02 04:58:00 UTC (rev 4134)
@@ -129,18 +129,50 @@
max_extent_exposedfield max_extent_;
openvrml::sfbool solid_;
- struct glyph_geometry {
- std::vector<openvrml::vec2f> coord;
- std::vector<openvrml::int32> coord_index;
- float advance_width;
- float advance_height;
+ class glyph_geometry {
+ std::vector<openvrml::vec2f> coord_;
+ std::vector<openvrml::int32> coord_index_;
+ float advance_width_;
+ float advance_height_;
- glyph_geometry(const std::vector<std::vector<openvrml::vec2f> > & contours,
- float advance_width,
- float advance_height)
+ public:
+ glyph_geometry(FT_Face face, FT_UInt glyph_index, float size)
OPENVRML_THROW1(std::bad_alloc);
+
+ const std::vector<openvrml::vec2f> & coord() const;
+ const std::vector<openvrml::int32> & coord_index() const;
+ float advance_width() const;
+ float advance_height() const;
};
+ class line_geometry {
+ const bool horizontal_;
+ const bool left_to_right_;
+ const bool top_to_bottom_;
+
+ std::vector<openvrml::vec2f> coord_;
+ std::vector<openvrml::int32> coord_index_;
+ float x_min_, x_max_, y_min_, y_max_;
+ std::size_t polygons_;
+ openvrml::vec2f pen_pos_;
+
+ public:
+ line_geometry(bool horizontal,
+ bool left_to_right,
+ bool top_to_bottom);
+
+ const std::vector<openvrml::vec2f> & coord() const;
+ const std::vector<openvrml::int32> & coord_index() const;
+ float x_min() const;
+ float x_max() const;
+ float y_min() const;
+ float y_max() const;
+ std::size_t polygons() const;
+
+ void add(const glyph_geometry & glyph);
+ void scale(float length);
+ };
+
struct text_geometry {
std::vector<openvrml::vec3f> coord;
std::vector<openvrml::int32> coord_index;
@@ -541,26 +573,26 @@
*/
/**
- * @var std::vector<openvrml::vec2f> text_node::glyph_geometry::coord
+ * @var std::vector<openvrml::vec2f> text_node::glyph_geometry::coord_
*
* @brief Glyph coordinates.
*/
/**
- * @var std::vector<openvrml::int32> text_node::glyph_geometry::coord_index
+ * @var std::vector<openvrml::int32> text_node::glyph_geometry::coord_index_
*
* @brief Glyph coordinate indices.
*/
/**
- * @var float text_node::glyph_geometry::advance_width
+ * @var float text_node::glyph_geometry::advance_width_
*
* @brief The distance the pen should advance horizontally after drawing
* the glyph.
*/
/**
- * @var float text_node::glyph_geometry::advance_height
+ * @var float text_node::glyph_geometry::advance_height_
*
* @brief The distance the pen should advance vertically after drawing the
* glyph.
@@ -951,40 +983,502 @@
std::vector<openvrml::vec2f> & coord;
std::vector<openvrml::int32> & coord_index;
};
+
+
+ struct OPENVRML_LOCAL GlyphContours_ {
+ const float scale;
+ std::vector<std::vector<openvrml::vec2f> > contours;
+
+ explicit GlyphContours_(float scale);
+ };
+
+ GlyphContours_::GlyphContours_(const float scale):
+ scale(scale)
+ {}
+
+ const float stepSize_ = 0.2f;
+
+ extern "C" int
+ moveTo_(const FT_Vector * const to,
+ void * const user)
+ {
+ using std::vector;
+ using openvrml::vec2f;
+ using openvrml::make_vec2f;
+
+ assert(user);
+ GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
+ try {
+ c.contours.push_back(vector<vec2f>(1));
+ } catch (std::bad_alloc & ex) {
+ OPENVRML_PRINT_EXCEPTION_(ex);
+ return FT_Err_Out_Of_Memory;
+ }
+ const vec2f vertex = make_vec2f(to->x * c.scale, to->y * c.scale);
+ c.contours.back().front() = vertex;
+ return 0;
+ }
+
+ extern "C" int
+ lineTo_(const FT_Vector * const to,
+ void * const user)
+ {
+ using openvrml::make_vec2f;
+
+ assert(user);
+ GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
+ const openvrml::vec2f vertex = make_vec2f(to->x * c.scale,
+ to->y * c.scale);
+ try {
+ c.contours.back().push_back(vertex);
+ } catch (std::bad_alloc & ex) {
+ OPENVRML_PRINT_EXCEPTION_(ex);
+ return FT_Err_Out_Of_Memory;
+ }
+ return 0;
+ }
+
+ /**
+ * @brief de Casteljau's algorithm.
+ *
+ * This is a nice recursive algorithm defined by de-Casteljau which
+ * calculates for a given control polygon the point that lies on the bezier
+ * curve for any value of t, and can be used to evaluate and draw the
+ * Bezier spline without using the Bernstein polynomials.
+ *
+ * The algorithm advances by creating in each step a polygons of degree one
+ * less than the one created in the previous step until there is only one
+ * point left, which is the point on the curve. The polygon vertices for
+ * each step are defined by linear interpolation of two consecutive
+ * vertices of the polygon from the previous step with a value of t (the
+ * parameter):
+ *
+ * @param buffer an array including the control points for the curve in
+ * the first @p npoints elements. The total size of the
+ * array must be @p npoints * @p npoints. The remaining
+ * elements of the array will be used by the algorithm to
+ * store temporary values.
+ * @param npoints the number of control points.
+ * @param contour the points on the curve are added to this array.
+ *
+ * @exception std::bad_alloc if memory allocation fails.
+ */
+ OPENVRML_LOCAL void evaluateCurve_(openvrml::vec2f * const buffer,
+ const size_t npoints,
+ std::vector<openvrml::vec2f> & contour)
+ OPENVRML_THROW1(std::bad_alloc)
+ {
+ for (size_t i = 1; i <= (1 / stepSize_); i++){
+ const float t = i * stepSize_; // Parametric points 0 <= t <= 1
+ for (size_t j = 1; j < npoints; j++) {
+ for (size_t k = 0; k < (npoints - j); k++) {
+ openvrml::vec2f & element = buffer[j * npoints + k];
+ element.x((1 - t) * buffer[(j - 1) * npoints + k][0]
+ + t * buffer[(j - 1) * npoints + k + 1][0]);
+ element.y((1 - t) * buffer[(j - 1) * npoints + k][1]
+ + t * buffer[(j - 1) * npoints + k + 1][1]);
+ }
+ }
+ //
+ // Specify next vertex to be included on curve
+ //
+ contour.push_back(buffer[(npoints - 1) * npoints]); // throws std::bad_alloc
+ }
+ }
+
+ extern "C" int
+ conicTo_(const FT_Vector * const control,
+ const FT_Vector * const to,
+ void * const user)
+ {
+ using std::vector;
+ using openvrml::vec2f;
+ using openvrml::make_vec2f;
+
+ assert(control);
+ assert(to);
+ assert(user);
+
+ GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
+
+ assert(!c.contours.empty());
+ vector<vec2f> & contour = c.contours.back();
+ const vec2f & lastVertex = contour[contour.size() - 1];
+
+ assert(!contour.empty());
+ const size_t npoints = 3;
+ vec2f buffer[npoints * npoints] = {
+ make_vec2f(lastVertex[0], lastVertex[1]),
+ make_vec2f(control->x * c.scale, control->y * c.scale),
+ make_vec2f(to->x * c.scale, to->y * c.scale)
+ };
+
+ try {
+ evaluateCurve_(buffer, npoints, contour);
+ } catch (std::bad_alloc & ex) {
+ OPENVRML_PRINT_EXCEPTION_(ex);
+ return FT_Err_Out_Of_Memory;
+ }
+ return 0;
+ }
+
+ extern "C" int
+ cubicTo_(const FT_Vector * const control1,
+ const FT_Vector * const control2,
+ const FT_Vector * const to,
+ void * const user)
+ {
+ using std::vector;
+ using openvrml::vec2f;
+ using openvrml::make_vec2f;
+
+ assert(control1);
+ assert(control2);
+ assert(to);
+ assert(user);
+
+ GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
+
+ assert(!c.contours.empty());
+ vector<vec2f> & contour = c.contours.back();
+ assert(!contour.empty());
+ const vec2f & lastVertex = contour.back();
+
+ static const size_t npoints = 4;
+ vec2f buffer[npoints * npoints] = {
+ make_vec2f(lastVertex[0], lastVertex[1]),
+ make_vec2f(control1->x * c.scale, control1->y * c.scale),
+ make_vec2f(control2->x * c.scale, control2->y * c.scale),
+ make_vec2f(to->x * c.scale, to->y * c.scale)
+ };
+
+ try {
+ evaluateCurve_(buffer, npoints, contour);
+ } catch (std::bad_alloc & ex) {
+ OPENVRML_PRINT_EXCEPTION_(ex);
+ return FT_Err_Out_Of_Memory;
+ }
+ return 0;
+ }
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
/**
* @brief Construct from a set of contours.
*
- * @param contours a vector of closed contours that make up the
- * glyph's outline.
- * @param advance_width the distance the pen should advance
- * horizontally after drawing the glyph.
- * @param advance_height the distance the pen should advance vertically
- * after drawing the glyph.
+ * @param[in,out] face a FreeType font face.
+ * @param[in] glyph_index the glyph's index (from <a href="http://freetype.sourceforge.net/freetype2/docs/reference/ft2-base_interface.html#FT_Get_Char_Index">@c FT_Get_Char_Index</a>).
+ * @param[in] size the desired size for the glyph.
*
* @exception std::bad_alloc if memory allocation fails.
*/
text_node::glyph_geometry::
- glyph_geometry(const std::vector<std::vector<openvrml::vec2f> > & contours,
- const float advance_width,
- const float advance_height)
+ glyph_geometry(const FT_Face face,
+ const FT_UInt glyph_index,
+ const float size)
OPENVRML_THROW1(std::bad_alloc):
- advance_width(advance_width),
- advance_height(advance_height)
+ advance_width_(0),
+ advance_height_(0)
{
# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
using std::vector;
+ using namespace boost::multi_index::detail; // for scope_guard
- const vector<polygon_> & polygons = get_polygons_(contours);
+ FT_Error error = FT_Err_Ok;
+ error = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE);
+ assert(error == FT_Err_Ok);
+ FT_Glyph glyph;
+ error = FT_Get_Glyph(face->glyph, &glyph);
+ assert(error == FT_Err_Ok);
+ scope_guard glyph_guard = make_guard(FT_Done_Glyph, glyph);
+ static FT_Outline_Funcs outlineFuncs = { moveTo_,
+ lineTo_,
+ conicTo_,
+ cubicTo_,
+ 0,
+ 0 };
+ const float glyphScale = (face->bbox.yMax > 0.0)
+ ? size / face->bbox.yMax
+ : size;
+ GlyphContours_ glyphContours(glyphScale);
+ assert(glyph->format == FT_GLYPH_FORMAT_OUTLINE);
+ const FT_OutlineGlyph outlineGlyph =
+ static_cast<FT_OutlineGlyph>(static_cast<void *>(glyph));
+ error = FT_Outline_Decompose(&outlineGlyph->outline,
+ &outlineFuncs,
+ &glyphContours);
+ assert(error == FT_Err_Ok);
+
+ assert(face->glyph);
+ this->advance_width_ =
+ FT_HAS_HORIZONTAL(face)
+ ? face->glyph->metrics.horiAdvance * glyphScale
+ : 0.0f;
+ this->advance_height_ =
+ FT_HAS_VERTICAL(face)
+ ? face->glyph->metrics.vertAdvance * glyphScale
+ : 0.0f;
+
+ const vector<polygon_> & polygons =
+ get_polygons_(glyphContours.contours);
std::for_each(polygons.begin(), polygons.end(),
- draw_glyph_polygon(this->coord, this->coord_index));
+ draw_glyph_polygon(this->coord_, this->coord_index_));
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
}
/**
+ * @brief The glyph coordinates.
+ *
+ * @return the glyph coordinates.
+ */
+ const std::vector<openvrml::vec2f> &
+ text_node::glyph_geometry::coord() const
+ {
+ return this->coord_;
+ }
+
+ /**
+ * @brief The glyph coordinate indices.
+ *
+ * @return Coordinate indices describing polygons for the glyph.
+ */
+ const std::vector<openvrml::int32> &
+ text_node::glyph_geometry::coord_index() const
+ {
+ return this->coord_index_;
+ }
+
+ /**
+ * @brief The horizontal distance the cursor should advance in order to
+ * accommodate this glyph.
+ *
+ * @return the horizontal distance the cursor should advance in order to
+ * accommodate this glyph.
+ */
+ float text_node::glyph_geometry::advance_width() const
+ {
+ return this->advance_width_;
+ }
+
+ /**
+ * @brief The vertical distance the cursor should advance in order to
+ * accommodate this glyph.
+ *
+ * @return the vertical distance the cursor should advance in order to
+ * accommodate this glyph.
+ */
+ float text_node::glyph_geometry::advance_height() const
+ {
+ return this->advance_height_;
+ }
+
+
+ /**
* @internal
*
+ * @class text_node::line_geometry
+ *
+ * @brief Geometry data for a line of text.
+ */
+
+ /**
+ * @var const bool text_node::line_geometry::horizontal_
+ *
+ * @brief @c true if text should be rendered horizontally; @c false if
+ * text should be rendered vertically.
+ */
+
+ /**
+ * @var const bool text_node::line_geometry::left_to_right_
+ *
+ * @brief @c true if text should be rendered left-to-right; @c false if
+ * text should be rendered right-to-left.
+ */
+
+ /**
+ * @var const bool text_node::line_geometry::top_to_bottom_
+ *
+ * @brief @c true if text should flow from top to bottom; @c false if text
+ * should flow from bottom to top.
+ */
+
+ /**
+ * @var std::vector<openvrml::vec2f> text_node::line_geometry::coord_
+ *
+ * @brief Coordinate data for the line of text.
+ */
+
+ /**
+ * @var std::vector<openvrml::int32> text_node::line_geometry::coord_index_
+ *
+ * @brief Coordinate indices describing polygons.
+ */
+
+ /**
+ * @var float text_node::line_geometry::x_min_
+ *
+ * @brief Minimum <var>x</var> coordinate.
+ */
+
+ /**
+ * @var float text_node::line_geometry::x_max_
+ *
+ * @brief Maximum <var>x</var> coordinate.
+ */
+
+ /**
+ * @var float text_node::line_geometry::y_min_
+ *
+ * @brief Minimum <var>y</var> coordinate.
+ */
+
+ /**
+ * @var float text_node::line_geometry::y_max_
+ *
+ * @brief Maximum <var>y</var> coordinate.
+ */
+
+ /**
+ * @var std::size_t text_node::line_geometry::polygons_
+ *
+ * @brief The number of polygons in the line.
+ */
+
+ /**
+ * @var float text_node::line_geometry::pen_x_
+ *
+ * @brief The “pen” position <var>x</var> coordinate.
+ */
+
+ /**
+ * @var float text_node::line_geometry::pen_y_
+ *
+ * @brief The “pen” position <var>y</var> coordinate.
+ */
+
+ /**
+ * @internal
+ *
+ * @brief Construct.
+ *
+ * @param[in] horizontal @c true if text is being rendered horizontally;
+ * @c false if text is being rendered vertically.
+ * @param[in] left_to_right @c true if text is being rendered left-to-right;
+ * @c false if text is being rendered right-to-
+ * left.
+ * @param[in] top_to_bottom @c true if text is being rendered top-to-bottom;
+ * @c false if text is being rendered bottom-to-
+ * top.
+ */
+ text_node::line_geometry::line_geometry(const bool horizontal,
+ const bool left_to_right,
+ const bool top_to_bottom):
+ horizontal_(horizontal),
+ left_to_right_(left_to_right),
+ top_to_bottom_(top_to_bottom),
+ x_min_(0), x_max_(0), y_min_(0), y_max_(0),
+ polygons_(0),
+ pen_pos_(openvrml::make_vec2f())
+ {}
+
+ const std::vector<openvrml::vec2f> & text_node::line_geometry::coord() const
+ {
+ return this->coord_;
+ }
+
+ const std::vector<openvrml::int32> &
+ text_node::line_geometry::coord_index() const
+ {
+ return this->coord_index_;
+ }
+
+ float text_node::line_geometry::x_min() const
+ {
+ return this->x_min_;
+ }
+
+ float text_node::line_geometry::x_max() const
+ {
+ return this->x_max_;
+ }
+
+ float text_node::line_geometry::y_min() const
+ {
+ return this->y_min_;
+ }
+
+ float text_node::line_geometry::y_max() const
+ {
+ return this->y_max_;
+ }
+
+ std::size_t text_node::line_geometry::polygons() const
+ {
+ return this->polygons_;
+ }
+
+ /**
+ * @internal
+ *
+ * @brief Add geometry for a glyph to the line.
+ *
+ * @param[in] glyph geometry data for a glyph.
+ */
+ void text_node::line_geometry::add(const glyph_geometry & glyph)
+ {
+ using openvrml::vec2f;
+ using std::min;
+ using std::max;
+
+ for (size_t i = 0; i < glyph.coord().size(); ++i) {
+ const vec2f textVertex = glyph.coord()[i] + this->pen_pos_;
+ this->coord_.push_back(textVertex);
+ this->x_min_ = min(this->x_min_, textVertex[0]);
+ this->x_max_ = max(this->x_max_, textVertex[0]);
+ this->y_min_ = min(this->y_min_, textVertex[1]);
+ this->y_max_ = max(this->y_max_, textVertex[1]);
+ }
+
+ for (size_t i = 0; i < glyph.coord_index().size(); ++i) {
+ const long index = glyph.coord_index()[i];
+ if (index > -1) {
+ const size_t offset =
+ this->coord_.size() - glyph.coord().size();
+ this->coord_index_.push_back(
+ static_cast<openvrml::int32>(offset + index));
+ } else {
+ this->coord_index_.push_back(-1);
+ ++this->polygons_;
+ }
+ }
+
+ if (this->horizontal_) {
+ if (this->left_to_right_) {
+ this->pen_pos_.vec[0] += glyph.advance_width();
+ } else {
+ this->pen_pos_.vec[0] -= glyph.advance_width();
+ }
+ } else {
+ if (this->top_to_bottom_) {
+ this->pen_pos_.vec[1] -= glyph.advance_height();
+ } else {
+ this->pen_pos_.vec[1] += glyph.advance_height();
+ }
+ }
+ }
+
+ void text_node::line_geometry::scale(const float length)
+ {
+ const float current_length = this->x_max_ - this->x_min_;
+ const float scale_factor = current_length * length;
+ for (size_t i = 0; i < this->coord_.size(); ++i) {
+ this->coord_[i].vec[0] /= scale_factor;
+ }
+ }
+
+
+ /**
+ * @internal
+ *
* @struct text_node::text_geometry
*
* @brief Holds the text geometry.
@@ -1086,7 +1580,10 @@
* @brief Destroy.
*/
text_node::~text_node() OPENVRML_NOTHROW
- {}
+ {
+ // shutdown sets this->face to 0.
+ assert(this->face == 0);
+ }
/**
* @brief Determine whether the node has been modified.
@@ -1133,8 +1630,7 @@
*
* @exception std::bad_alloc if memory allocation fails.
*/
- void text_node::do_initialize(double)
- OPENVRML_THROW1(std::bad_alloc)
+ void text_node::do_initialize(double) OPENVRML_THROW1(std::bad_alloc)
{
this->update_ucs4();
this->update_face();
@@ -1146,13 +1642,13 @@
*
* @param timestamp the current time.
*/
- void text_node::do_shutdown(double)
- OPENVRML_NOTHROW
+ void text_node::do_shutdown(double) OPENVRML_NOTHROW
{
# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
if (this->face) {
FT_Error ftError = FT_Done_Face(this->face);
assert(ftError == FT_Err_Ok); // Surely this can't fail.
+ this->face = 0;
}
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
}
@@ -1729,185 +2225,7 @@
# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
}
-# ifdef OPENVRML_ENABLE_RENDER_TEXT_NODE
- struct OPENVRML_LOCAL GlyphContours_ {
- const float scale;
- std::vector<std::vector<openvrml::vec2f> > contours;
-
- explicit GlyphContours_(float scale);
- };
-
- GlyphContours_::GlyphContours_(const float scale):
- scale(scale)
- {}
-
- const float stepSize_ = 0.2f;
-
- extern "C" int
- moveTo_(OPENVRML_FT_CONST FT_Vector * const to,
- void * const user)
- {
- using std::vector;
- using openvrml::vec2f;
- using openvrml::make_vec2f;
-
- assert(user);
- GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
- try {
- c.contours.push_back(vector<vec2f>(1));
- } catch (std::bad_alloc & ex) {
- OPENVRML_PRINT_EXCEPTION_(ex);
- return FT_Err_Out_Of_Memory;
- }
- const vec2f vertex = make_vec2f(to->x * c.scale, to->y * c.scale);
- c.contours.back().front() = vertex;
- return 0;
- }
-
- extern "C" int
- lineTo_(OPENVRML_FT_CONST FT_Vector * const to,
- void * const user)
- {
- using openvrml::make_vec2f;
-
- assert(user);
- GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
- const openvrml::vec2f vertex = make_vec2f(to->x * c.scale,
- to->y * c.scale);
- try {
- c.contours.back().push_back(vertex);
- } catch (std::bad_alloc & ex) {
- OPENVRML_PRINT_EXCEPTION_(ex);
- return FT_Err_Out_Of_Memory;
- }
- return 0;
- }
-
/**
- * @brief de Casteljau's algorithm.
- *
- * This is a nice recursive algorithm defined by de-Casteljau which
- * calculates for a given control polygon the point that lies on the bezier
- * curve for any value of t, and can be used to evaluate and draw the
- * Bezier spline without using the Bernstein polynomials.
- *
- * The algorithm advances by creating in each step a polygons of degree one
- * less than the one created in the previous step until there is only one
- * point left, which is the point on the curve. The polygon vertices for
- * each step are defined by linear interpolation of two consecutive
- * vertices of the polygon from the previous step with a value of t (the
- * parameter):
- *
- * @param buffer an array including the control points for the curve in
- * the first @p npoints elements. The total size of the
- * array must be @p npoints * @p npoints. The remaining
- * elements of the array will be used by the algorithm to
- * store temporary values.
- * @param npoints the number of control points.
- * @param contour the points on the curve are added to this array.
- *
- * @exception std::bad_alloc if memory allocation fails.
- */
- OPENVRML_LOCAL void evaluateCurve_(openvrml::vec2f * const buffer,
- const size_t npoints,
- std::vector<openvrml::vec2f> & contour)
- OPENVRML_THROW1(std::bad_alloc)
- {
- for (size_t i = 1; i <= (1 / stepSize_); i++){
- const float t = i * stepSize_; // Parametric points 0 <= t <= 1
- for (size_t j = 1; j < npoints; j++) {
- for (size_t k = 0; k < (npoints - j); k++) {
- openvrml::vec2f & element = buffer[j * npoints + k];
- element.x((1 - t) * buffer[(j - 1) * npoints + k][0]
- + t * buffer[(j - 1) * npoints + k + 1][0]);
- element.y((1 - t) * buffer[(j - 1) * npoints + k][1]
- + t * buffer[(j - 1) * npoints + k + 1][1]);
- }
- }
- //
- // Specify next vertex to be included on curve
- //
- contour.push_back(buffer[(npoints - 1) * npoints]); // throws std::bad_alloc
- }
- }
-
- extern "C" int
- conicTo_(OPENVRML_FT_CONST FT_Vector * const control,
- OPENVRML_FT_CONST FT_Vector * const to,
- void * const user)
- {
- using std::vector;
- using openvrml::vec2f;
- using openvrml::make_vec2f;
-
- assert(control);
- assert(to);
- assert(user);
-
- GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
-
- assert(!c.contours.empty());
- vector<vec2f> & contour = c.contours.back();
- const vec2f & lastVertex = contour[contour.size() - 1];
-
- assert(!contour.empty());
- const size_t npoints = 3;
- vec2f buffer[npoints * npoints] = {
- make_vec2f(lastVertex[0], lastVertex[1]),
- make_vec2f(control->x * c.scale, control->y * c.scale),
- make_vec2f(to->x * c.scale, to->y * c.scale)
- };
-
- try {
- evaluateCurve_(buffer, npoints, contour);
- } catch (std::bad_alloc & ex) {
- OPENVRML_PRINT_EXCEPTION_(ex);
- return FT_Err_Out_Of_Memory;
- }
- return 0;
- }
-
- extern "C" int
- cubicTo_(OPENVRML_FT_CONST FT_Vector * const control1,
- OPENVRML_FT_CONST FT_Vector * const control2,
- OPENVRML_FT_CONST FT_Vector * const to,
- void * const user)
- {
- using std::vector;
- using openvrml::vec2f;
- using openvrml::make_vec2f;
-
- assert(control1);
- assert(control2);
- assert(to);
- assert(user);
-
- GlyphContours_ & c = *static_cast<GlyphContours_ *>(user);
-
- assert(!c.contours.empty());
- vector<vec2f> & contour = c.contours.back();
- assert(!contour.empty());
- const vec2f & lastVertex = contour.back();
-
- static const size_t npoints = 4;
- vec2f buffer[npoints * npoints] = {
- make_vec2f(lastVertex[0], lastVertex[1]),
- make_vec2f(control1->x * c.scale, control1->y * c.scale),
- make_vec2f(control2->x * c.scale, control2->y * c.scale),
- make_vec2f(to->x * c.scale, to->y * c.scale)
- };
-
- try {
- evaluateCurve_(buffer, npoints, contour);
- } catch (std::bad_alloc & ex) {
- OPENVRML_PRINT_EXCEPTION_(ex);
- return FT_Err_Out_Of_Memory;
- }
- return 0;
- }
-# endif // OPENVRML_ENABLE_RENDER_TEXT_NODE
-
- /**
* @brief Called to update @a text_geometry.
*
* @exception std::bad_alloc if memory allocation fails.
@@ -1932,7 +2250,7 @@
float spacing = 1.0;
openvrml::font_style_node * fontStyle =
node_cast<openvrml::font_style_node *>(
- this->font_style_.sfnode::value().get());
+ this->font_style_.value().get());
if (fontStyle) {
horizontal = fontStyle->horizontal();
if (!fontStyle->justify().empty()) {
@@ -1975,17 +2293,7 @@
using openvrml::int32;
- struct LineGeometry {
- vector<vec2f> coord;
- vector<int32> coordIndex;
- float xMin, xMax;
- float yMin, yMax;
-
- LineGeometry(): xMin(0.0), xMax(0.0), yMin(0.0), yMax(0.0)
- {}
- };
-
- LineGeometry lineGeometry;
+ line_geometry line_geom(horizontal, leftToRight, topToBottom);
for (vector<char32_t>::const_iterator character = string->begin();
character != string->end(); ++character) {
assert(this->face);
@@ -2002,120 +2310,27 @@
if (pos != this->glyph_geometry_map.end()) {
glyphGeometry = &pos->second;
} else {
- FT_Error error = FT_Err_Ok;
- error = FT_Load_Glyph(this->face,
- glyphIndex,
- FT_LOAD_NO_SCALE);
- assert(error == FT_Err_Ok);
- FT_Glyph glyph;
- error = FT_Get_Glyph(this->face->glyph, &glyph);
- assert(error == FT_Err_Ok);
- static FT_Outline_Funcs outlineFuncs = { moveTo_,
- lineTo_,
- conicTo_,
- cubicTo_,
- 0,
- 0 };
- const float glyphScale = (this->face->bbox.yMax > 0.0)
- ? size / this->face->bbox.yMax
- : size;
- GlyphContours_ glyphContours(glyphScale);
- assert(glyph->format == ft_glyph_format_outline);
- const FT_OutlineGlyph outlineGlyph =
- reinterpret_cast<FT_OutlineGlyph>(glyph);
- error = FT_Outline_Decompose(&outlineGlyph->outline,
- &outlineFuncs,
- &glyphContours);
- assert(error == FT_Err_Ok);
-
- assert(this->face->glyph);
- const float advanceWidth =
- FT_HAS_HORIZONTAL(this->face)
- ? this->face->glyph->metrics.horiAdvance * glyphScale
- : 0.0f;
- const float advanceHeight =
- FT_HAS_VERTICAL(this->face)
- ? this->face->glyph->metrics.vertAdvance * glyphScale
- : 0.0f;
-
const glyph_geometry_map_t::value_type
value(glyphIndex,
- glyph_geometry(glyphContours.contours,
- advanceWidth,
- advanceHeight));
+ glyph_geometry(this->face, glyphIndex, size));
const pair<glyph_geometry_map_t::iterator, bool> result =
this->glyph_geometry_map.insert(value);
assert(result.second);
glyphGeometry = &result.first->second;
}
+ assert(glyphGeometry);
+ lin...
[truncated message content] |