Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
78f7994976 | |||
8c7557e45d | |||
e51afb851c | |||
8661a5ca62 | |||
a83d494d45 | |||
d3aae9b262 | |||
b96550ab24 | |||
c6cad702bc | |||
23bcd70199 | |||
aa319e4144 | |||
ec48743fb9 | |||
9c877a0244 | |||
f3970f641e | |||
2acccd7261 | |||
d2fadaea7b | |||
1721f6cef4 | |||
3483f34fa9 | |||
e374903061 | |||
2977ad5113 | |||
9b65804de2 | |||
60e80180c6 | |||
c7d13fca9e | |||
1c1be8a7c1 | |||
78e3b85274 | |||
ea36ed50d8 |
21
README.md
@ -2,9 +2,10 @@
|
||||
|
||||
This modpack provides mods with dynamic display. Mods are :
|
||||
|
||||
- **display_lib**: A library for adding display entities to nodes;
|
||||
- **font_lib**: A library for displaying fonts on entities;
|
||||
- **display_api**: A library for adding display entities to nodes;
|
||||
- **font_api**: A library for displaying fonts on entities;
|
||||
- **ontime_clocks**: A mod providing clocks which display the ingame time;
|
||||
- **signs_api**: A library for the easy creation of signs;
|
||||
- **signs**: A mod providing signs and direction signs displaying text;
|
||||
- **signs_road**: A mod providing road signs displaying text;
|
||||
- **steles**: A mod providing stone steles with text;
|
||||
@ -15,6 +16,22 @@ For more information, see the [forum topic](https://forum.minetest.net/viewtopic
|
||||
|
||||
## Changelog
|
||||
|
||||
### 2018-05-30 (Version 1.0.1)
|
||||
|
||||
Mostly bug fixes :
|
||||
|
||||
- Fix steles orientation when placing
|
||||
|
||||
- Update entity on mapblock load
|
||||
|
||||
- Use default formspec style
|
||||
|
||||
- Fix ndef nill value in steles mod when technics not installed
|
||||
|
||||
- Seperate signs API from signs définitions
|
||||
|
||||
- Allow a greater offset between display and block
|
||||
|
||||
### 2018-01-13 (Version 1.0)
|
||||
|
||||
- Switch to Epilepsy font by KREATIVE SOFTWARE
|
||||
|
94
display_api/API.md
Normal file
@ -0,0 +1,94 @@
|
||||
# Display Lib API
|
||||
This document describes Display Lib API. Display Lib allows to add a dynamic display on a node. Display Lib limits node rotations. For wallmounted, only vertical positionning is available, and for facedir, only first four position are availabel (those with default axis).
|
||||
|
||||
## Provided methods
|
||||
### update\_entities
|
||||
**display\_lib.update\_entities(pos)**
|
||||
|
||||
This method triggers entities update for the display node at pos. Actual entity update is made by `on_display_update` callback associated to the entity.
|
||||
|
||||
`pos`: Position of the node
|
||||
### register\_display\_entity
|
||||
**display\_lib.register\_display\_entity(entity_name)**
|
||||
|
||||
This is a helper to register entities used for display.
|
||||
|
||||
`entity_name`: Name of the entity to register.
|
||||
## Provided callback implementations
|
||||
### on_place
|
||||
**display\_lib.on\_place(itemstack, placer, pointed\_thing)**
|
||||
|
||||
`on_place` node callback implementation. Display nodes should have this callback (avoid placement of horizontal display node).
|
||||
### on_construct
|
||||
**display\_lib.on\_construct(pos)**
|
||||
|
||||
`on_construct` node callback implementation. Display nodes should have this callback (creates, places and updates display entities on node construction).
|
||||
### on_destruct
|
||||
**display\_lib.on_destruct(pos)**
|
||||
|
||||
`on_destruct` node callback implementation. Display nodes should have this callback (removes display entities on node destruction).
|
||||
### on_rotate
|
||||
**display\_lib.on\_rotate(pos, node, user, mode, new_param2)**
|
||||
|
||||
`on_rotate` node callback implementation. Display nodes should have this callback (restricts rotations and rotates display entities associated with node).
|
||||
### on_activate
|
||||
**display\_lib.on_activate(entity, staticdata)**
|
||||
|
||||
`On_activate` entity callback implementation for display entities. No need of this method if display entities have been registered using `register_display_entity` (callback is already set).
|
||||
|
||||
## Howto register a display node
|
||||
* Register display entities with `register_display_entity`
|
||||
|
||||
* Register node with :
|
||||
- `on_place`, `on_construct`, `on_destruct` and `on_rotate` callbacks using display_api callbacks.
|
||||
|
||||
- `display_modpack_node` group. This will make this node have their entities updated as soon as the mapblock is loaded (Useful after /clearobjects).
|
||||
|
||||
- a `display_entities` field in node definition containing a entity name indexed table. See below for description of each display_entities fields.
|
||||
|
||||
### Display_entities fields
|
||||
`on_display_update` is a callback in charge of setting up entity texture. If not set, entity will have no texture and will be displayed as unknown item.
|
||||
|
||||
`depth`, `right` and `height` : Entity position regarding to node facedir/wallmounted main axis.
|
||||
Values for these fields can be any number between -1.5 and 1.5 (default value is 0).
|
||||
Position 0,0,0 is the center of the node.
|
||||
`depth` goes from front (-0.5) to rear (0.5), `height` goes from bottom (-0.5) to top (0.5) and `right` goes from left (-0.5) to right (0.5).
|
||||
|
||||
In order to avoid flickering text, it's better to have text a little behind node surface. A good spacing value is given by `display_api.entity_spacing` variable.
|
||||
|
||||
### Example
|
||||
|
||||
display_api.register_display_entity("mymod:entity1")
|
||||
display_api.register_display_entity("mymod:entity2")
|
||||
|
||||
function my_display_update1(pos, objref)
|
||||
objref:set_properties({ textures= {"mytexture1.png"},
|
||||
visual_size = {x=1, y=1} })
|
||||
end
|
||||
|
||||
function my_display_update2(pos, objref)
|
||||
objref:set_properties({ textures= {"mytexture2.png"},
|
||||
visual_size = {x=1, y=1} })
|
||||
end
|
||||
|
||||
minetest.register_node("mymod:test_display_node", {
|
||||
...
|
||||
paramtype2 = "facedir",
|
||||
...
|
||||
groups = { display_modpack_node = 1, ... },
|
||||
...
|
||||
display_entities = {
|
||||
["mymod:entity1"] = {
|
||||
depth = 0.3,
|
||||
on_display_update = my_display_update1 },
|
||||
["mymod:entity1"] = {
|
||||
depth = 0.2, height = 0.1,
|
||||
on_display_update = my_display_update2 },
|
||||
},
|
||||
...
|
||||
on_place = display_api.on_place,
|
||||
on_construct = display_api.on_construct,
|
||||
on_destruct = display_api.on_destruct,
|
||||
on_rotate = display_api.on_rotate,
|
||||
...
|
||||
})
|
@ -8,7 +8,7 @@ This library's purpose is to ease creation of nodes with one or more displays on
|
||||
|
||||
**License**: LPGL
|
||||
|
||||
**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/display_lib/API.md) document please.
|
||||
**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/display_api/API.md) document please.
|
||||
|
||||
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums.
|
||||
|
4
display_api/copyright.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Code by Pierre-Yves Rollo (pyrollo)
|
||||
Contributors:
|
||||
(gpcf): Compatibility with signs lib
|
||||
(Thomas--S): Fix /clearobjects bug
|
@ -1,5 +1,5 @@
|
||||
--[[
|
||||
display_lib mod for Minetest - Library to add dynamic display
|
||||
display_api mod for Minetest - Library to add dynamic display
|
||||
capabilities to nodes
|
||||
(c) Pierre-Yves Rollo
|
||||
|
||||
@ -17,7 +17,12 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
display_lib = {}
|
||||
display_api = {}
|
||||
|
||||
-- Prefered gap between node and entity
|
||||
-- Entity positionment is up to mods but it is a good practice to use this
|
||||
-- variable as spacing between entity and node
|
||||
display_api.entity_spacing = 0.002
|
||||
|
||||
-- Miscelaneous values depending on wallmounted param2
|
||||
local wallmounted_values = {
|
||||
@ -74,14 +79,25 @@ local function get_values(node)
|
||||
end
|
||||
end
|
||||
|
||||
--- Checks if the object is related to the given position
|
||||
local function check_entity_pos(pos, objref)
|
||||
local real_pos = vector.round(objref:get_pos())
|
||||
local pos_hash = objref:get_luaentity().pos
|
||||
if pos_hash == nil then
|
||||
return vector.equals(real_pos, vector.round(pos))
|
||||
else
|
||||
return vector.equals(minetest.get_position_from_hash(pos_hash), pos)
|
||||
end
|
||||
end
|
||||
|
||||
--- Gets the display entities attached with a node. Removes extra ones
|
||||
local function get_entities(pos)
|
||||
local objrefs = {}
|
||||
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if ndef and ndef.display_entities then
|
||||
for _, objref in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do
|
||||
for _, objref in ipairs(minetest.get_objects_inside_radius(pos, 1.5)) do
|
||||
local entity = objref:get_luaentity()
|
||||
if entity and ndef.display_entities[entity.name] then
|
||||
if entity and ndef.display_entities[entity.name] and check_entity_pos(pos, objref) then
|
||||
if objrefs[entity.name] then
|
||||
objref:remove()
|
||||
else
|
||||
@ -95,7 +111,7 @@ end
|
||||
|
||||
local function clip_pos_prop(posprop)
|
||||
if posprop then
|
||||
return math.max(-0.5, math.min(0.5, posprop))
|
||||
return math.max(-1.5, math.min(1.5, posprop))
|
||||
else
|
||||
return 0
|
||||
end
|
||||
@ -112,15 +128,15 @@ local function place_entities(pos)
|
||||
|
||||
for entity_name, props in pairs(ndef.display_entities) do
|
||||
local depth = clip_pos_prop(props.depth)
|
||||
local height = clip_pos_prop(props.height)
|
||||
local right = clip_pos_prop(props.right)
|
||||
local top = clip_pos_prop(props.top)
|
||||
if not objrefs[entity_name] then
|
||||
objrefs[entity_name] = minetest.add_entity(pos, entity_name)
|
||||
end
|
||||
|
||||
objrefs[entity_name]:setpos({
|
||||
x = pos.x - values.dx * depth + values.rx * right,
|
||||
y = pos.y + height,
|
||||
y = pos.y - top,
|
||||
z = pos.z - values.dz * depth + values.rz * right})
|
||||
|
||||
objrefs[entity_name]:setyaw(values.yaw)
|
||||
@ -139,25 +155,38 @@ local function call_node_on_display_update(pos, objref)
|
||||
end
|
||||
|
||||
--- Force entity update
|
||||
function display_lib.update_entities(pos)
|
||||
function display_api.update_entities(pos)
|
||||
local objrefs = place_entities(pos)
|
||||
for _, objref in pairs(objrefs) do
|
||||
objref:get_luaentity().pos = minetest.hash_node_position(pos)
|
||||
call_node_on_display_update(pos, objref)
|
||||
end
|
||||
end
|
||||
|
||||
--- On_activate callback for display_lib entities. Calls on_display_update callbacks
|
||||
--- On_activate callback for display_api entities. Calls on_display_update callbacks
|
||||
--- of corresponding node for each entity.
|
||||
function display_lib.on_activate(entity, staticdata)
|
||||
function display_api.on_activate(entity, staticdata)
|
||||
if entity then
|
||||
if string.sub(staticdata, 1, string.len("return")) == "return" then
|
||||
local data = core.deserialize(staticdata)
|
||||
if data and type(data) == "table" then
|
||||
entity.pos = data.pos
|
||||
end
|
||||
end
|
||||
entity.object:set_armor_groups({immortal=1})
|
||||
call_node_on_display_update(entity.object:getpos(), entity.object)
|
||||
local pos
|
||||
if entity.pos then
|
||||
pos = minetest.get_position_from_hash(entity.pos)
|
||||
else
|
||||
pos = entity.object:getpos()
|
||||
end
|
||||
display_api.update_entities(pos)
|
||||
end
|
||||
end
|
||||
|
||||
--- On_place callback for display_lib items. Does nothing more than preventing item
|
||||
--- On_place callback for display_api items. Does nothing more than preventing item
|
||||
--- from being placed on ceiling or ground
|
||||
function display_lib.on_place(itemstack, placer, pointed_thing)
|
||||
function display_api.on_place(itemstack, placer, pointed_thing)
|
||||
local ndef = itemstack:get_definition()
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
@ -184,13 +213,13 @@ function display_lib.on_place(itemstack, placer, pointed_thing)
|
||||
|
||||
end
|
||||
|
||||
--- On_construct callback for display_lib items. Creates entities and update them.
|
||||
function display_lib.on_construct(pos)
|
||||
display_lib.update_entities(pos)
|
||||
--- On_construct callback for display_api items. Creates entities and update them.
|
||||
function display_api.on_construct(pos)
|
||||
display_api.update_entities(pos)
|
||||
end
|
||||
|
||||
--- On_destruct callback for display_lib items. Removes entities.
|
||||
function display_lib.on_destruct(pos)
|
||||
--- On_destruct callback for display_api items. Removes entities.
|
||||
function display_api.on_destruct(pos)
|
||||
local objrefs = get_entities(pos)
|
||||
|
||||
for _, objref in pairs(objrefs) do
|
||||
@ -198,8 +227,8 @@ function display_lib.on_destruct(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- On_rotate (screwdriver) callback for display_lib items. Prevents axis rotation and reorients entities.
|
||||
function display_lib.on_rotate(pos, node, user, mode, new_param2)
|
||||
-- On_rotate (screwdriver) callback for display_api items. Prevents axis rotation and reorients entities.
|
||||
function display_api.on_rotate(pos, node, user, mode, new_param2)
|
||||
if mode ~= 1 then return false end
|
||||
|
||||
local values = get_values(node)
|
||||
@ -214,16 +243,29 @@ function display_lib.on_rotate(pos, node, user, mode, new_param2)
|
||||
end
|
||||
|
||||
--- Creates display entity with some fields and the on_activate callback
|
||||
function display_lib.register_display_entity(entity_name)
|
||||
function display_api.register_display_entity(entity_name)
|
||||
if not minetest.registered_entity then
|
||||
minetest.register_entity(':'..entity_name, {
|
||||
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
||||
visual = "upright_sprite",
|
||||
textures = {},
|
||||
on_activate = display_lib.on_activate,
|
||||
on_activate = display_api.on_activate,
|
||||
get_staticdata = function(self)
|
||||
return minetest.serialize({
|
||||
pos = self.pos,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "Update display_api entities",
|
||||
name = "display_api:update_entities",
|
||||
run_at_every_load = true,
|
||||
nodenames = {"group:display_modpack_node", "group:display_lib_node"},
|
||||
action = function(pos, node) display_api.update_entities(pos) end,
|
||||
})
|
||||
|
||||
|
||||
-- Compatibility
|
||||
display_lib = display_api
|
@ -1,83 +0,0 @@
|
||||
# Display Lib API
|
||||
This document describes Display Lib API. Display Lib allows to add a dynamic display on a node. Display Lib limits node rotations. For wallmounted, only vertical positionning is available, and for facedir, only first four position are availabel (those with default axis).
|
||||
|
||||
## Provided methods
|
||||
### update\_entities
|
||||
**display\_lib.update\_entities(pos)**
|
||||
|
||||
This method triggers entities update for the display node at pos. Actual entity update is made by **on\_display\_update** callback associated to the entity.
|
||||
|
||||
**pos**: Position of the node
|
||||
### register\_display\_entity
|
||||
**display\_lib.register\_display\_entity(entity_name)**
|
||||
|
||||
This is a helper to register entities used for display.
|
||||
|
||||
**entity_name**: Name of the entity to register.
|
||||
## Provided callback implementations
|
||||
### on_place
|
||||
**display\_lib.on\_place(itemstack, placer, pointed\_thing)**
|
||||
|
||||
**On_place** node callback implementation. Display nodes should have this callback (avoid placement of horizontal display node).
|
||||
### on_construct
|
||||
**display\_lib.on\_construct(pos)**
|
||||
|
||||
**On_construct** node callback implementation. Display nodes should have this callback (creates, places and updates display entities on node construction).
|
||||
### on_destruct
|
||||
**display\_lib.on_destruct(pos)**
|
||||
|
||||
**On_destruct** node callback implementation. Display nodes should have this callback (removes display entities on node destruction).
|
||||
### on_rotate
|
||||
**display\_lib.on\_rotate(pos, node, user, mode, new_param2)**
|
||||
|
||||
**On_rotate** node callback implementation. Display nodes should have this callback (restricts rotations and rotates display entities associated with node).
|
||||
### on_activate
|
||||
**display\_lib.on_activate(entity, staticdata)**
|
||||
|
||||
**On_activate** entity callback implementation for display entities. No need of this method if display entities have been registered using **register\_display\_entity** (callback is already set).
|
||||
## Howto register a display node
|
||||
* Register display entities with **register\_display\_entity**
|
||||
* Register node with :
|
||||
- **on\_place**, **on\_construct**, **on\_destruct** and **on\_rotate** callbacks using **display\_lib** callbacks.
|
||||
- a **display\_entities** field in node definition containing a entity name indexed table. See below for description of each display\_entities fields.
|
||||
|
||||
### Display_entities fields
|
||||
**depth**, **right** and **height** : Entity position regarding to node facedir/wallmounted main axis. Values for these fields can be any number between -0.5 and 0.5 (default value is 0). Position 0,0,0 is the center of the node. **depth** goes from front (-0.5) to rear (0.5), **height** goes from bottom (-0.5) to top (0.5) and **height** goes from left (-0.5) to right (0.5).
|
||||
|
||||
**on_display_update** is a callback in charge of setting up entity texture. If not set, entity will have no texture and will be displayed as unknown item.
|
||||
|
||||
### Example
|
||||
|
||||
display_lib.register_display_entity("mymod:entity1")
|
||||
display_lib.register_display_entity("mymod:entity2")
|
||||
|
||||
function my_display_update1(pos, objref)
|
||||
objref:set_properties({ textures= {"mytexture1.png"},
|
||||
visual_size = {x=1, y=1} })
|
||||
end
|
||||
|
||||
function my_display_update2(pos, objref)
|
||||
objref:set_properties({ textures= {"mytexture2.png"},
|
||||
visual_size = {x=1, y=1} })
|
||||
end
|
||||
|
||||
minetest.register_node("mymod:test_display_node", {
|
||||
...
|
||||
paramtype2 = "wallmounted",
|
||||
...
|
||||
display_entities = {
|
||||
["mymod:entity1"] = { depth = 0.3,
|
||||
on_display_update = my_display_update1},
|
||||
["mymod:entity1"] = { depth = 0.2, height = 0.1,
|
||||
on_display_update = my_display_update2},
|
||||
},
|
||||
...
|
||||
on_place = display_lib.on_place,
|
||||
on_construct = display_lib.on_construct,
|
||||
on_destruct = display_lib.on_destruct,
|
||||
on_rotate = display_lib.on_rotate,
|
||||
...
|
||||
})
|
||||
|
||||
|
||||
|
145
font_api/API.md
Normal file
@ -0,0 +1,145 @@
|
||||
# Font Lib API
|
||||
This document describes Font Lib API. Font Lib creates textures for font display on entities.
|
||||
|
||||
## Settings
|
||||
### default_font
|
||||
Name of the font to be used when no font is given. The font should be registered.
|
||||
|
||||
If no default\_font given or if default\_font given but not registered, the first registered font will be used as default.
|
||||
|
||||
## Provided methods
|
||||
|
||||
### font_api.get_default_font_name()
|
||||
Returns de default font name.
|
||||
|
||||
### font_api.register_font(font_name, font_def)
|
||||
Register a new font.
|
||||
**font_name**: Name of the font to register. If registering different sizes of the same font, add size in the font name (e.g. times_10, times_12...).
|
||||
**font_def**: Font definition table (see **Font definition table** below).
|
||||
|
||||
### font_api.on_display_update(pos, objref)
|
||||
Standard on_display_update entity callback.
|
||||
|
||||
**pos**: Node position
|
||||
|
||||
**objref**: Object reference of entity
|
||||
|
||||
Node should have a corresponding display_entity with size, resolution and maxlines fields and optionally halign, valign and color fields.
|
||||
|
||||
### Font definition table
|
||||
Font definition table used by **font_api.register_font** and **font\_api.Font:new** may/can contain following elements:
|
||||
|
||||
* **height** (required): Font height in pixels (all font textures should have the same height) .
|
||||
* **widths** (required): Array of character widths in pixels, indexed by UTF codepoints.
|
||||
* **margintop** (optional): Margin (in texture pixels) added on top of each char texture.
|
||||
* **marginbottom** (optional): Margin (in texture pixels) added at bottom of each char texture.
|
||||
* **linespacing** (optional): Spacing (in texture pixels) between each lines.
|
||||
|
||||
**margintop**, **marginbottom** and **linespacing** can be negative numbers (default 0) and are to be used to adjust various font styles to each other.
|
||||
|
||||
Font must have a char 0 which will be used to display any unknown char.
|
||||
|
||||
All textures corresponding to the indexes in widths array should be present in textures directory with a name matching the pattern :
|
||||
|
||||
> font\_**{font_name}**_**{utf_code}**.png
|
||||
|
||||
**{font\_name}**: Name of the font as given in the first argument
|
||||
|
||||
**{utf\_code}**: UTF code of the char in 4 hexadecimal digits
|
||||
|
||||
Example : font_courrier_0041.png is for the "A" char in the "courrier" font.
|
||||
|
||||
To ease that declaration (specially to build the **widths** array), a shell is provided to build a {font\_name}.lua file from the texture files (see provided tools).
|
||||
|
||||
## Provided tools
|
||||
|
||||
Still in early stage of development, these tools are helpers to create font mods.
|
||||
|
||||
### make_font_texture.sh
|
||||
|
||||
This scripts takes a .ttf file as input and create one .png file per char, that can be used as font texture. Launch it from your future font mod directory.
|
||||
|
||||
__Advice__
|
||||
|
||||
This script works much better with pixels font, providing the correct height. There is no antialiasing at all, vector fonts and bad heights gives very ugly results.
|
||||
|
||||
__Syntax__
|
||||
|
||||
**make\_font\_texture.sh {fontfile} {fontname} {fontsize}**
|
||||
|
||||
**{fontfile}**: A TTF font file to use to create textures.
|
||||
**{fontname}**: The font name to be used in font_api (should be simple, with no spaces).
|
||||
**{fontsize}**: Font height to be rendered.
|
||||
|
||||
### make_font_lua.sh
|
||||
|
||||
This script analyses textures in textures directory and creates a font\_{font\_name}.lua files with a call to register_font with images information. Launch it from your future font mod directory.
|
||||
|
||||
Once the font\_{font\_name}.lua created, it can be included by a init.lua file or directly renamed to init.lua if you are creating a simple font mod.
|
||||
|
||||
__Syntax__
|
||||
|
||||
**make\_font_lua.sh {fontname}**
|
||||
|
||||
**{fontname}**: The font name to be used in font_api (same as given to make\_font\_texture.sh)
|
||||
|
||||
### An exemple generating a font mod
|
||||
|
||||
mkdir font_myfont
|
||||
cd font_myfont
|
||||
/<path_to_font_api>/tools/make_font_texture.sh myfont.ttf myfont 12
|
||||
/<path_to_font_api>/tools/make_font_lua.sh myfont
|
||||
mv font_myfont.lua init.lua
|
||||
|
||||
## Font class
|
||||
A font usable with font API. This class is supposed to be for internal use but who knows.
|
||||
|
||||
### font\_api.Font:new(def)
|
||||
Create a new font object.
|
||||
|
||||
**def** is a table containing font definition. See **Font definition table** above.
|
||||
|
||||
### font:get_char_width(char)
|
||||
Returns the width of char **char** in texture pixels.
|
||||
|
||||
**char**: Unicode codepoint of char.
|
||||
|
||||
### font:get_height(nb_of_lines)
|
||||
Returns line(s) height. Takes care of top and bottom margins and line spacing.
|
||||
|
||||
**nb_of_lines**: Number of lines in the text.
|
||||
|
||||
### font:get_width(line)
|
||||
|
||||
Returns the width of a text line. Beware, if line contains any new line char, they are ignored.
|
||||
|
||||
**line**: Line of text which the width will be computed.
|
||||
|
||||
### font:make_line_texture(line, texturew, x, y)
|
||||
Create a texture for a text line.
|
||||
|
||||
**line**: Line of text to be rendered in texture.
|
||||
|
||||
**texturew**: Width of the texture (extra text is not rendered).
|
||||
|
||||
**x**: Starting x position in texture.
|
||||
|
||||
**y**: Vertical position of the line in texture.
|
||||
|
||||
### font:make_text_texture(text, texturew, textureh, maxlines, halign, valign, color)
|
||||
Builds texture for a multiline colored text.
|
||||
|
||||
**text**: Text to be rendered.
|
||||
|
||||
**texturew**: Width of the texture (extra text will be truncated).
|
||||
|
||||
**textureh**: Height of the texture.
|
||||
|
||||
**maxlines**: Maximum number of lines.
|
||||
|
||||
**halign**: Horizontal text align ("left"/"center"/"right") (optional).
|
||||
|
||||
**valign**: Vertical text align ("top"/"center"/"bottom") (optional).
|
||||
|
||||
**color**: Color of the text (optional).
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Font Lib
|
||||
|
||||
This library for font display on entities (to be used with display_lib for sign creation).
|
||||
This library for font display on entities (to be used with display_api for sign creation).
|
||||
|
||||
**Dependancies**: default
|
||||
|
||||
@ -8,7 +8,7 @@ This library for font display on entities (to be used with display_lib for sign
|
||||
|
||||
(Default font taken from VanessaE's homedecor/signs_lib, originally under WTFPL)
|
||||
|
||||
**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/font_lib/API.md) document please.
|
||||
**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/font_api/API.md) document please.
|
||||
|
||||
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=13563) at the Minetest forums.
|
||||
|
3
font_api/copyright.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Code by Pierre-Yves Rollo (pyrollo)
|
||||
Contributors:
|
||||
Andrzej Pieńkowski (apienk): Unicode support and tool for creating texturess
|
463
font_api/doc/font.svg
Normal file
@ -0,0 +1,463 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="120mm"
|
||||
height="110mm"
|
||||
viewBox="0 0 120 110"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
|
||||
sodipodi:docname="font.svg">
|
||||
<defs
|
||||
id="defs2">
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7159"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7157"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7071"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7069"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mend"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path886"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mstart"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path883"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path880"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path877"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-3"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-6"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-7"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-5"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-1"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-2"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-7"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-9-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-1-3"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-2-6"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-7-0"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-1"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-2"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-3"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-94"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-7"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-8"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-4"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="-151.37352"
|
||||
inkscape:cy="445.54867"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="g8201"
|
||||
showgrid="true"
|
||||
inkscape:lockguides="true"
|
||||
inkscape:window-width="1877"
|
||||
inkscape:window-height="1052"
|
||||
inkscape:window-x="1409"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
showguides="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid826"
|
||||
spacingx="1"
|
||||
units="mm"
|
||||
spacingy="1" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-187)">
|
||||
<g
|
||||
id="g7357"
|
||||
transform="translate(65,-15)"
|
||||
style="opacity:0.5">
|
||||
<rect
|
||||
y="202"
|
||||
x="170"
|
||||
height="70"
|
||||
width="70"
|
||||
id="rect828-9"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:0.25098039;fill-rule:nonzero;stroke:#999999;stroke-width:0.30550504;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
d="m 220,252 h 10 v 10 h -10 z m -50,0 h 10 v 10 h -10 z m 5,-10 h 50 v 10 h -50 z m 4.99998,-10 h 10 v 10 h -10 z M 210,232 h 10 v 10 h -10 z m -5,-10 h 10 v 10 h -10 z m -20,0 h 10 v 10 h -10 z m 5,-10.00002 h 20 v 10 H 190 Z M 195,202 h 10 v 10 h -10 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32659864;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect854-2"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
<g
|
||||
id="g8201"
|
||||
transform="translate(0,190)">
|
||||
<rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499998, 1.05999994;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect1594"
|
||||
width="120"
|
||||
height="109.99999"
|
||||
x="0"
|
||||
y="-3" />
|
||||
<g
|
||||
transform="translate(-75,-120)"
|
||||
id="g7361">
|
||||
<rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#0000ff;fill-opacity:0.25098039;fill-rule:nonzero;stroke:#0000ff;stroke-width:0.30550504;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect828"
|
||||
width="70"
|
||||
height="70"
|
||||
x="100"
|
||||
y="137" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="rect854"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32659864;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 150,187 h 10 v 10 h -10 z m -50,0 h 10 v 10 h -10 z m 5,-10 h 50 v 10 h -50 z m 4.99999,-10 h 10 v 10 h -10 z M 140,167 h 10 v 10 h -10 z m -5,-10 h 10 v 10 h -10 z m -20,0 h 10 v 10 h -10 z m 5,-10.00002 h 20 v 10 H 120 Z M 125,137 h 10 v 10 h -10 z" />
|
||||
</g>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875"
|
||||
d="M 19.999999,17 V 87"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart);marker-end:url(#Arrow1Lend)" />
|
||||
<text
|
||||
inkscape:transform-center-y="5.2916667"
|
||||
inkscape:transform-center-x="1.889881"
|
||||
transform="rotate(-90)"
|
||||
id="text1193"
|
||||
y="17.496948"
|
||||
x="-52.43602"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="17.496948"
|
||||
x="-52.43602"
|
||||
id="tspan1191"
|
||||
sodipodi:role="line">Texture Height</tspan></text>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-3"
|
||||
d="M 95,97 H 25"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-3);marker-end:url(#Arrow1Lend-7)" />
|
||||
<text
|
||||
inkscape:transform-center-y="-1.8898824"
|
||||
inkscape:transform-center-x="5.2916602"
|
||||
id="text1193-5"
|
||||
y="101.69528"
|
||||
x="60.176346"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="101.69528"
|
||||
x="60.176346"
|
||||
id="tspan1191-6"
|
||||
sodipodi:role="line">Texture Width</tspan></text>
|
||||
<rect
|
||||
y="7"
|
||||
x="25"
|
||||
height="85"
|
||||
width="70"
|
||||
id="rect828-2"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ff00ff;stroke-width:0.33665016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-0"
|
||||
d="M 20,7 V 17"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#marker7071);marker-end:url(#marker7159)" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-0-6"
|
||||
d="m 20,87 v 5"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Mstart);marker-end:url(#Arrow1Mend)" />
|
||||
<text
|
||||
inkscape:transform-center-y="-1.8898824"
|
||||
inkscape:transform-center-x="5.2916678"
|
||||
id="text1193-2"
|
||||
y="10.614426"
|
||||
x="17.348068"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:end;text-anchor:end;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="10.614426"
|
||||
x="17.348068"
|
||||
id="tspan1191-61"
|
||||
sodipodi:role="line">Margin</tspan><tspan
|
||||
id="tspan8103"
|
||||
style="text-align:end;text-anchor:end;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="15.575363"
|
||||
x="17.348068"
|
||||
sodipodi:role="line">Top</tspan></text>
|
||||
<text
|
||||
inkscape:transform-center-y="-1.8898824"
|
||||
inkscape:transform-center-x="5.2916678"
|
||||
id="text1193-2-8"
|
||||
y="88.4991"
|
||||
x="17.240334"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:end;text-anchor:end;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="88.4991"
|
||||
x="18.503822"
|
||||
id="tspan1191-61-7"
|
||||
sodipodi:role="line">Margin </tspan><tspan
|
||||
id="tspan8105"
|
||||
style="text-align:end;text-anchor:end;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="93.460037"
|
||||
x="17.240334"
|
||||
sodipodi:role="line">Bottom</tspan></text>
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-1"
|
||||
d="M 100,7 V 92"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-1);marker-end:url(#Arrow1Lend-9)" />
|
||||
<text
|
||||
inkscape:transform-center-y="5.2916667"
|
||||
inkscape:transform-center-x="1.889881"
|
||||
transform="rotate(-90)"
|
||||
id="text1193-0"
|
||||
y="104.35954"
|
||||
x="-49.646301"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="104.35954"
|
||||
x="-49.646301"
|
||||
id="tspan1191-3"
|
||||
sodipodi:role="line">Line Height</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 20 KiB |
544
font_api/doc/lines.svg
Normal file
@ -0,0 +1,544 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="120mm"
|
||||
height="225mm"
|
||||
viewBox="0 0 120 225"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
|
||||
sodipodi:docname="lines.svg">
|
||||
<defs
|
||||
id="defs2">
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7159"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7157"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker7071"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path7069"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mend"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path886"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Mstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Mstart"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path883"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.4,0,0,0.4,4,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path880"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path877"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-3"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-6"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-7"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-5"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-1"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-2"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-7"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-9-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-1-3"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-2-6"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-7-0"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-1"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-2"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-9"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-3"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-94"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-7"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-8"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-4"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-1-2"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-2-0"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-9-6"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-3-1"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lstart-1-5"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path877-2-4"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(0.8,0,0,0.8,10,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="Arrow1Lend-9-7"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path880-3-6"
|
||||
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1"
|
||||
transform="matrix(-0.8,0,0,-0.8,-10,0)" />
|
||||
</marker>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="1"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="577.84911"
|
||||
inkscape:cy="466.83879"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:lockguides="true"
|
||||
inkscape:window-width="1877"
|
||||
inkscape:window-height="1052"
|
||||
inkscape:window-x="1409"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
showguides="false">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid826"
|
||||
spacingx="1"
|
||||
units="mm"
|
||||
spacingy="1" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-72)">
|
||||
<rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499998, 1.05999993999999997;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect890"
|
||||
width="120"
|
||||
height="224.99998"
|
||||
x="0"
|
||||
y="72" />
|
||||
<g
|
||||
id="g10629"
|
||||
transform="translate(-5,-54.999998)">
|
||||
<g
|
||||
id="g8263">
|
||||
<g
|
||||
transform="translate(-40,39.999996)"
|
||||
id="g8268">
|
||||
<rect
|
||||
y="102"
|
||||
x="60"
|
||||
height="70"
|
||||
width="70"
|
||||
id="rect828-9"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:0.25098039;fill-rule:nonzero;stroke:#999999;stroke-width:0.30550504;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
d="m 110,152 h 10 v 10 h -10 z m -50,0 h 10 v 10 H 60 Z m 5,-10 h 50 v 10 H 65 Z m 4.99998,-10 h 10 v 10 h -10 z M 100,132 h 10 v 10 h -10 z m -5,-10 h 10 v 10 H 95 Z m -20,0 h 10 v 10 H 75 Z m 5,-10.00002 h 20 v 10 H 80 Z M 85,102 h 10 v 10 H 85 Z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32659864;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect854-2"
|
||||
inkscape:connector-curvature="0" />
|
||||
<rect
|
||||
y="92"
|
||||
x="60"
|
||||
height="85.000008"
|
||||
width="70"
|
||||
id="rect828-2-6"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#808080;stroke-width:0.33665016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(-40,170)"
|
||||
id="g8268-1">
|
||||
<rect
|
||||
y="102"
|
||||
x="60"
|
||||
height="70"
|
||||
width="70"
|
||||
id="rect828-9-0"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:0.25098039;fill-rule:nonzero;stroke:#999999;stroke-width:0.30550504;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
d="m 110,152 h 10 v 10 h -10 z m -50,0 h 10 v 10 H 60 Z m 5,-10 h 50 v 10 H 65 Z m 4.99998,-10 h 10 v 10 h -10 z M 100,132 h 10 v 10 h -10 z m -5,-10 h 10 v 10 H 95 Z m -20,0 h 10 v 10 H 75 Z m 5,-10.00002 h 20 v 10 H 80 Z M 85,102 h 10 v 10 H 85 Z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#808080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32659864;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect854-2-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
<rect
|
||||
y="92"
|
||||
x="60"
|
||||
height="85.000008"
|
||||
width="70"
|
||||
id="rect828-2-6-3"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#808080;stroke-width:0.33665016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
transform="translate(-75,70)"
|
||||
id="g7361">
|
||||
<rect
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#0000ff;fill-opacity:0.25098039;fill-rule:nonzero;stroke:#0000ff;stroke-width:0.30550504;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
id="rect828"
|
||||
width="70"
|
||||
height="70"
|
||||
x="100"
|
||||
y="137" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="rect854"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#0000ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.32659864;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 150,187 h 10 v 10 h -10 z m -50,0 h 10 v 10 h -10 z m 5,-10 h 50 v 10 h -50 z m 4.99999,-10 h 10 v 10 h -10 z M 140,167 h 10 v 10 h -10 z m -5,-10 h 10 v 10 h -10 z m -20,0 h 10 v 10 h -10 z m 5,-10.00002 h 20 v 10 H 120 Z M 125,137 h 10 v 10 h -10 z" />
|
||||
</g>
|
||||
<rect
|
||||
y="197"
|
||||
x="25"
|
||||
height="85"
|
||||
width="70"
|
||||
id="rect828-2"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.98000004;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ff00ff;stroke-width:0.33665016;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-1"
|
||||
d="m 100,197 v 85"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-1);marker-end:url(#Arrow1Lend-9)" />
|
||||
<text
|
||||
inkscape:transform-center-y="5.2916667"
|
||||
inkscape:transform-center-x="1.889881"
|
||||
transform="rotate(-90)"
|
||||
id="text1193-0"
|
||||
y="104.35954"
|
||||
x="-239.6463"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="104.35954"
|
||||
x="-239.6463"
|
||||
id="tspan1191-3"
|
||||
sodipodi:role="line">Line Height</tspan></text>
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-1-5"
|
||||
d="m 15,197 v 20"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-1-2);marker-end:url(#Arrow1Lend-9-6)" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path875-1-56"
|
||||
d="M 110,132 V 347"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-1-5);marker-end:url(#Arrow1Lend-9-7)" />
|
||||
<text
|
||||
inkscape:transform-center-y="5.2916667"
|
||||
inkscape:transform-center-x="1.889881"
|
||||
transform="rotate(-90)"
|
||||
id="text1193-0-9"
|
||||
y="115.82679"
|
||||
x="-239.6463"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="115.82679"
|
||||
x="-239.6463"
|
||||
id="tspan1191-3-3"
|
||||
sodipodi:role="line">Text Height</tspan></text>
|
||||
<text
|
||||
inkscape:transform-center-y="5.2916667"
|
||||
inkscape:transform-center-x="1.889881"
|
||||
transform="rotate(-90)"
|
||||
id="text1193-0-7"
|
||||
y="11.713711"
|
||||
x="-206.76294"
|
||||
style="font-style:normal;font-weight:normal;font-size:3.96875px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke-width:0.26458332px"
|
||||
y="11.713711"
|
||||
x="-206.76294"
|
||||
id="tspan1191-3-4"
|
||||
sodipodi:role="line">Line Spacing</tspan></text>
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512"
|
||||
d="M 25,197 H 15 v 0"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999996;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512-5"
|
||||
d="M 25,217 H 15 v 0"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999996;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512-2"
|
||||
d="M 110,132 H 90"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999996;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512-2-5"
|
||||
d="M 110,347 H 90"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999997;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512-2-5-4"
|
||||
d="M 100,282 H 95"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999998;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path10512-2-5-4-7"
|
||||
d="M 100,197 H 95"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:0.26499999, 1.05999999;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 25 KiB |
267
font_api/font.lua
Normal file
@ -0,0 +1,267 @@
|
||||
--[[
|
||||
font_api mod for Minetest - Library to add font display capability
|
||||
to display_api mod.
|
||||
(c) Pierre-Yves Rollo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
-- Local functions
|
||||
------------------
|
||||
|
||||
-- Table deep copy
|
||||
|
||||
local function deep_copy(input)
|
||||
local output = {}
|
||||
local key, value
|
||||
for key, value in pairs(input) do
|
||||
if type(value) == 'table' then
|
||||
output[key] = deep_copy(value)
|
||||
else
|
||||
output[key] = value
|
||||
end
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
-- Returns next char, managing ascii and unicode plane 0 (0000-FFFF).
|
||||
|
||||
local function get_next_char(text, pos)
|
||||
|
||||
local msb = text:byte(pos)
|
||||
-- 1 byte char, ascii equivalent codepoints
|
||||
if msb < 0x80 then
|
||||
return msb, pos + 1
|
||||
end
|
||||
|
||||
-- 4 bytes char not managed (Only 16 bits codepoints are managed)
|
||||
if msb >= 0xF0 then
|
||||
return 0, pos + 4
|
||||
end
|
||||
|
||||
-- 3 bytes char
|
||||
if msb >= 0xE0 then
|
||||
return (msb - 0xE0) * 0x1000
|
||||
+ text:byte(pos + 1) % 0x40 * 0x40
|
||||
+ text:byte(pos + 2) % 0x40,
|
||||
pos + 3
|
||||
end
|
||||
|
||||
-- 2 bytes char (little endian)
|
||||
if msb >= 0xC2 then
|
||||
return (msb - 0xC2) * 0x40 + text:byte(pos + 1),
|
||||
pos + 2
|
||||
end
|
||||
|
||||
-- Not an UTF char
|
||||
return 0, pos + 1
|
||||
end
|
||||
|
||||
-- Split multiline text into array of lines, with <maxlines> maximum lines.
|
||||
|
||||
local function split_lines(text, maxlines)
|
||||
local splits = text:split("\n")
|
||||
if maxlines then
|
||||
local lines = {}
|
||||
for num = 1,maxlines do
|
||||
lines[num] = splits[num]
|
||||
end
|
||||
return lines
|
||||
else
|
||||
return splits
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
--- Font class
|
||||
|
||||
font_api.Font = {}
|
||||
|
||||
function font_api.Font:new(def)
|
||||
|
||||
if type(def) ~= "table" then
|
||||
minetest.log("error", "Font definition must be a table.")
|
||||
return nil
|
||||
end
|
||||
|
||||
if def.height == nil or def.height <= 0 then
|
||||
minetest.log("error", "Font definition must have a positive height.")
|
||||
return nil
|
||||
end
|
||||
|
||||
if type(def.widths) ~= "table" then
|
||||
minetest.log("error", "Font definition must have a widths array.")
|
||||
return nil
|
||||
end
|
||||
|
||||
if def.widths[0] == nil then
|
||||
minetest.log("error",
|
||||
"Font must have a char with codepoint 0 (=unknown char).")
|
||||
return nil
|
||||
end
|
||||
|
||||
local font = deep_copy(def)
|
||||
setmetatable(font, self)
|
||||
self.__index = self
|
||||
return font
|
||||
end
|
||||
|
||||
--- Returns the width of a given char
|
||||
-- @param char : codepoint of the char
|
||||
-- @return Char width
|
||||
|
||||
function font_api.Font:get_char_width(char)
|
||||
-- Replace chars with no texture by the NULL(0) char
|
||||
if self.widths[char] ~= nil then
|
||||
return self.widths[char]
|
||||
else
|
||||
return self.widths[0]
|
||||
end
|
||||
end
|
||||
|
||||
--- Text height for multiline text including margins and line spacing
|
||||
-- @param nb_of_lines : number of text lines (default 1)
|
||||
-- @return Text height
|
||||
|
||||
function font_api.Font:get_height(nb_of_lines)
|
||||
if nb_of_lines == nil then nb_of_lines = 1 end
|
||||
|
||||
if nb_of_lines > 0 then
|
||||
return
|
||||
(
|
||||
(self.height or 0) +
|
||||
(self.margintop or 0) +
|
||||
(self.marginbottom or 0)
|
||||
) * nb_of_lines +
|
||||
(self.linespacing or 0) * (nb_of_lines -1)
|
||||
else
|
||||
return nb_of_lines == 0 and 0 or nil
|
||||
end
|
||||
end
|
||||
|
||||
--- Computes text width for a given text (ignores new lines)
|
||||
-- @param line Line of text which the width will be computed.
|
||||
-- @return Text width
|
||||
|
||||
function font_api.Font:get_width(line)
|
||||
|
||||
local char
|
||||
local width = 0
|
||||
local pos = 1
|
||||
|
||||
-- TODO: Use iterator
|
||||
while pos <= #line do
|
||||
char, pos = get_next_char(line, pos)
|
||||
width = width + self:get_char_width(char)
|
||||
end
|
||||
|
||||
return width
|
||||
end
|
||||
|
||||
--- Builds texture part for a text line
|
||||
-- @param line Text line to be rendered
|
||||
-- @param texturew Width of the texture (extra text is not rendered)
|
||||
-- @param x Starting x position in texture
|
||||
-- @param y Vertical position of the line in texture
|
||||
-- @return Texture string
|
||||
|
||||
function font_api.Font:make_line_texture(line, texturew, x, y)
|
||||
local texture = ""
|
||||
local char
|
||||
local pos = 1
|
||||
|
||||
-- TODO: Use iterator
|
||||
while pos <= #line do
|
||||
char, pos = get_next_char(line, pos)
|
||||
|
||||
-- Replace chars with no texture by the NULL(0) char
|
||||
if self.widths[char] == nil
|
||||
or char == 88
|
||||
then
|
||||
print(string.format("["..font_api.name
|
||||
.."] Missing char %d (%04x)",char,char))
|
||||
char = 0
|
||||
end
|
||||
|
||||
-- Add image only if it is visible (at least partly)
|
||||
if x + self.widths[char] >= 0 and x <= texturew then
|
||||
texture = texture..
|
||||
string.format(":%d,%d=font_%s_%04x.png",
|
||||
x, y, self.name, char)
|
||||
end
|
||||
x = x + self.widths[char]
|
||||
end
|
||||
|
||||
return texture
|
||||
end
|
||||
|
||||
--- Builds texture for a multiline colored text
|
||||
-- @param text Text to be rendered
|
||||
-- @param texturew Width of the texture (extra text will be truncated)
|
||||
-- @param textureh Height of the texture
|
||||
-- @param maxlines Maximum number of lines
|
||||
-- @param halign Horizontal text align ("left"/"center"/"right") (optional)
|
||||
-- @param valign Vertical text align ("top"/"center"/"bottom") (optional)
|
||||
-- @param color Color of the text (optional)
|
||||
-- @return Texture string
|
||||
|
||||
function font_api.Font:make_text_texture(text, texturew, textureh, maxlines,
|
||||
halign, valign, color)
|
||||
local texture = ""
|
||||
local lines = {}
|
||||
local textheight = 0
|
||||
local y
|
||||
|
||||
-- Split text into lines (limited to maxlines fist lines)
|
||||
for num, line in pairs(split_lines(text, maxlines)) do
|
||||
lines[num] = { text = line, width = self:get_width(line) }
|
||||
end
|
||||
|
||||
textheight = self:get_height(#lines)
|
||||
|
||||
if #lines then
|
||||
if valign == "top" then
|
||||
y = 0
|
||||
elseif valign == "bottom" then
|
||||
y = textureh - textheight
|
||||
else
|
||||
y = (textureh - textheight) / 2
|
||||
end
|
||||
end
|
||||
|
||||
y = y + (self.margintop or 0)
|
||||
|
||||
for _, line in pairs(lines) do
|
||||
if halign == "left" then
|
||||
texture = texture..
|
||||
self:make_line_texture(line.text, texturew,
|
||||
0, y)
|
||||
elseif halign == "right" then
|
||||
texture = texture..
|
||||
self:make_line_texture(line.text, texturew,
|
||||
texturew - line.width, y)
|
||||
else
|
||||
texture = texture..
|
||||
self:make_line_texture(line.text, texturew,
|
||||
(texturew - line.width) / 2, y)
|
||||
end
|
||||
|
||||
y = y + self:get_height() + (self.linespacing or 0)
|
||||
end
|
||||
|
||||
texture = string.format("[combine:%dx%d", texturew, textureh)..texture
|
||||
if color then texture = texture.."^[colorize:"..color end
|
||||
return texture
|
||||
end
|
||||
|
64
font_api/init.lua
Normal file
@ -0,0 +1,64 @@
|
||||
--[[
|
||||
font_api mod for Minetest - Library to add font display capability
|
||||
to display_api mod.
|
||||
(c) Pierre-Yves Rollo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
-- Global variables
|
||||
-------------------
|
||||
|
||||
font_api = {}
|
||||
font_api.name = minetest.get_current_modname()
|
||||
font_api.path = minetest.get_modpath(font_api.name)
|
||||
|
||||
-- Inclusions
|
||||
-------------
|
||||
|
||||
dofile(font_api.path.."/font.lua")
|
||||
dofile(font_api.path.."/registry.lua")
|
||||
|
||||
--- Standard on_display_update entity callback.
|
||||
-- Node should have a corresponding display_entity with size, resolution and
|
||||
-- maxlines fields and optionally halign, valign and color fields
|
||||
-- @param pos Node position
|
||||
-- @param objref Object reference of entity
|
||||
|
||||
function font_api.on_display_update(pos, objref)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local text = meta:get_string("display_text")
|
||||
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
local entity = objref:get_luaentity()
|
||||
|
||||
if entity and ndef.display_entities[entity.name] then
|
||||
local def = ndef.display_entities[entity.name]
|
||||
local font = font_api.get_font(meta:get_string("font") or def.font_name)
|
||||
|
||||
local maxlines = def.maxlines or 1 -- TODO:How to do w/o maxlines ?
|
||||
|
||||
objref:set_properties({
|
||||
textures={font:make_text_texture(text,
|
||||
font:get_height(maxlines) * def.size.x / def.size.y
|
||||
/ (def.aspect_ratio or 1),
|
||||
font:get_height(maxlines),
|
||||
def.maxlines, def.halign, def.valign, def.color)},
|
||||
visual_size = def.size
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Compatibility
|
||||
font_lib = font_api
|
||||
|
151
font_api/registry.lua
Normal file
@ -0,0 +1,151 @@
|
||||
--[[
|
||||
font_api mod for Minetest - Library to add font display capability
|
||||
to display_api mod.
|
||||
(c) Pierre-Yves Rollo
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
-- Global variables
|
||||
-------------------
|
||||
|
||||
font_api.registered_fonts = {}
|
||||
font_api.registered_fonts_number = 0
|
||||
|
||||
-- Local variables
|
||||
------------------
|
||||
|
||||
local default_font = false
|
||||
|
||||
-- Local functions
|
||||
------------------
|
||||
|
||||
-- Gets a default (settings or fist font)
|
||||
local function get_default_font()
|
||||
-- First call
|
||||
if default_font == false then
|
||||
default_font = nil
|
||||
|
||||
-- First, try with settings
|
||||
local settings_font = minetest.settings:get("default_font")
|
||||
|
||||
if settings_font ~= nil and settings_font ~= "" then
|
||||
default_font = font_api.registered_fonts[settings_font]
|
||||
|
||||
if default_font == nil then
|
||||
minetest.log("warning", "Default font in settings (\""..
|
||||
settings_font.."\") is not registered.")
|
||||
end
|
||||
end
|
||||
|
||||
-- If failed, choose first font
|
||||
if default_font == nil then
|
||||
for _, font in pairs(font_api.registered_fonts) do
|
||||
default_font = font
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Error, no font registered
|
||||
if default_font == nil then
|
||||
minetest.log("error",
|
||||
"No font registred, unable to choose a default font.")
|
||||
end
|
||||
end
|
||||
|
||||
return default_font
|
||||
end
|
||||
|
||||
--- Returns font object to be used according to font_name
|
||||
-- @param font_name: Name of the font
|
||||
-- @return Font object if font found (or default font)
|
||||
|
||||
function font_api.get_font(font_name)
|
||||
local font = font_api.registered_fonts[font_name]
|
||||
|
||||
if font == nil then
|
||||
local message
|
||||
|
||||
if font_name == nil then
|
||||
message = "No font given"
|
||||
else
|
||||
message = "Font \""..font_name.."\" unregistered"
|
||||
end
|
||||
|
||||
font = get_default_font()
|
||||
|
||||
if font ~= nil then
|
||||
minetest.log("info", message..", using font \""..font.name.."\".")
|
||||
end
|
||||
end
|
||||
|
||||
return font
|
||||
end
|
||||
|
||||
-- API functions
|
||||
----------------
|
||||
|
||||
--- Returns de default font name
|
||||
-- @return Default font name
|
||||
|
||||
function font_api.get_default_font_name()
|
||||
return get_default_font().name
|
||||
end
|
||||
|
||||
--- Register a new font
|
||||
-- Textures corresponding to the font should be named after following patern :
|
||||
-- font_<name>_<code>.png
|
||||
-- <name> : name of the font
|
||||
-- <code> : 4 digit hexadecimal unicode of the char
|
||||
-- @param font_name Name of the font to register
|
||||
-- If registering different sizes of the same font, add size in the font name
|
||||
-- (e.g. times_10, times_12...).
|
||||
-- @param def font definition. A associative array with following keys :
|
||||
-- @key height (mandatory) Height in pixels of all font textures
|
||||
-- @key widths (mandatory) Array of character widths in pixels, indexed by
|
||||
-- UTF codepoints
|
||||
-- @key margintop (optional) Margin (in texture pixels) added on top of each
|
||||
-- char texture.
|
||||
-- @key marginbottom (optional) dded at bottom of each char texture.
|
||||
-- @key linespacing (optional) Spacing (in texture pixels) between each lines.
|
||||
-- margintop, marginbottom and linespacing can be negative numbers (default 0)
|
||||
-- and are to be used to adjust various font styles to each other.
|
||||
|
||||
-- TODO: Add something to remove common accent if not defined in font
|
||||
|
||||
function font_api.register_font(font_name, font_def)
|
||||
|
||||
if font_api.registered_fonts[font_name] ~= nil then
|
||||
minetest.log("error", "Font \""..font_name.."\" already registered.")
|
||||
return
|
||||
end
|
||||
|
||||
local font = font_api.Font:new(font_def)
|
||||
|
||||
if font == nil then
|
||||
minetest.log("error", "Unable to register font \""..font_name.."\".")
|
||||
return
|
||||
end
|
||||
|
||||
font.name = font_name
|
||||
font_api.registered_fonts[font_name] = font
|
||||
font_api.registered_fonts_number = font_api.registered_fonts_number + 1
|
||||
|
||||
-- Force to choose again default font
|
||||
-- (allows use of fonts registered after start)
|
||||
default_font = false
|
||||
|
||||
minetest.log("action", "New font registered in font_api: "..font_name..".")
|
||||
end
|
||||
|
@ -3,6 +3,17 @@
|
||||
scriptname=$(basename $0)
|
||||
identify="identify"
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 fontname"
|
||||
echo "fontname: The name of the font. Must correspond to existing texture/font_<fontname>_????.png files"
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
font_name=$1
|
||||
|
||||
for f in textures/font_${font_name}_????.png
|
||||
@ -39,18 +50,22 @@ $luafile generated by $scriptname $(LANG=en_US date)
|
||||
|
||||
--]]
|
||||
|
||||
font_lib.register_font(
|
||||
font_api.register_font(
|
||||
'$font_name',
|
||||
$font_height,
|
||||
{ $font_widths }
|
||||
{
|
||||
height = $font_height,
|
||||
widths = {
|
||||
$font_widths
|
||||
},
|
||||
}
|
||||
);
|
||||
" > font_$font_name.lua
|
||||
|
||||
if grep -q font_lib depends.txt &>/dev/null
|
||||
if grep -q font_api depends.txt &>/dev/null
|
||||
then
|
||||
echo "font_lib already in depends.txt."
|
||||
echo "font_api already in depends.txt."
|
||||
else
|
||||
echo "adding font_lib to depends.txt."
|
||||
echo "font_lib" >> depends.txt
|
||||
echo "adding font_api to depends.txt."
|
||||
echo "font_api" >> depends.txt
|
||||
fi
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This program generates a bitmap font for font_lib mod for Minetest game.
|
||||
# This program generates a bitmap font for font_api mod for Minetest game.
|
||||
# (c) Andrzej Pieńkowski <pienkowski.andrzej@gmail.com>
|
||||
# (c) Pierre-Yves Rollo <dev@pyrollo.com>
|
||||
# License: GPL
|
||||
@ -8,7 +8,7 @@
|
||||
usage() {
|
||||
echo "Usage: $0 fontfile fontname fontsize"
|
||||
echo "fontfile: A TTF font file to use to create textures."
|
||||
echo "fontname: The font name to be used in font_lib (should be simple, with no spaces)."
|
||||
echo "fontname: The font name to be used in font_api (should be simple, with no spaces)."
|
||||
echo "fontsize: Font height to be rendered."
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ generate() {
|
||||
mkdir textures
|
||||
|
||||
# Reads all available code points in the font.
|
||||
codepoints=$(ttx -o - $fontfile | grep "<map code=" | cut -d \" -f 2)
|
||||
codepoints=$(ttx -o - "$fontfile" | grep "<map code=" | cut -d \" -f 2)
|
||||
|
||||
# Mandatory chars
|
||||
generate 0020 007f
|
@ -1,20 +0,0 @@
|
||||
KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE
|
||||
version 1.2f
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or entity (the "User") obtaining a copy of the included font files (the "Software") produced by Kreative Software, to utilize, display, embed, or redistribute the Software, subject to the following conditions:
|
||||
|
||||
1. The User may not sell copies of the Software for a fee.
|
||||
|
||||
1a. The User may give away copies of the Software free of charge provided this license and any documentation is included verbatim and credit is given to Kreative Korporation or Kreative Software.
|
||||
|
||||
2. The User may not modify, reverse-engineer, or create any derivative works of the Software.
|
||||
|
||||
3. Any Software carrying the following font names or variations thereof is not covered by this license and may not be used under the terms of this license: Jewel Hill, Miss Diode n Friends, This is Beckie's font!
|
||||
|
||||
3a. Any Software carrying a font name ending with the string "Pro CE" is not covered by this license and may not be used under the terms of this license.
|
||||
|
||||
4. This license becomes null and void if any of the above conditions are not met.
|
||||
|
||||
5. Kreative Software reserves the right to change this license at any time without notice.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE SOFTWARE OR FROM OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,12 +0,0 @@
|
||||
# Font Epilepsy
|
||||
|
||||
Font mod for font_lib mod.
|
||||
|
||||
**Font**: EpilepsySansBold by Kreative Software under KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE version 1.2f.
|
||||
|
||||
**Dependancies**:font_lib
|
||||
|
||||
**License**: LPGL for the cod, KREATIVE SOFTWARE RELAY FONTS FREE USE LICENSE version 1.2f for the font (see FONT LICENSE.txt)
|
||||
|
||||
For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums.
|
||||
|
@ -1 +0,0 @@
|
||||
font_lib
|
Before Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 322 B |
Before Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 288 B |
Before Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 328 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 313 B |
Before Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 303 B |
Before Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 299 B |
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 309 B |
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 322 B |
Before Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 313 B |
Before Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 304 B |
Before Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 316 B |
Before Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 308 B |
Before Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 318 B |
Before Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 290 B |