Code covered by the BSD License
-
getCharCoordinates(c, fontHei...
-
getStringCoordinates(font, in...
-
loadAndParseTFF(filename)
load and parse tff file
-
matprint(image, position, inp...
function [image] = matprint(image, position, inputString, color, font, fontHeight[, options])
-
parseChar(line, filename, ln)
-
processText(line)
-
main.m
-
View all files
from
matprint
by Karel Lebeda
Prints (rasterizes) text directly to image matrix.
|
| getCharCoordinates(c, fontHeight) |
function [coords] = getCharCoordinates(c, fontHeight)
gEntities = c.geomEntities;
coords = zeros(2,0);
for i = 1:length(gEntities)
ge = gEntities{i};
switch ge.type
case 'D'
xMin = round(fontHeight * (ge.x - ge.s/2));
yMin = round(fontHeight * (ge.y - ge.s/2));
xMax = round(fontHeight * (ge.x + ge.s/2));
yMax = round(fontHeight * (ge.y + ge.s/2));
[x, y] = meshgrid(xMin:xMax, yMin:yMax);
coords = [coords [x(:) y(:)]'];
case 'L'
numPts = ceil(sqrt((ge.x1-ge.x2).^2 + (ge.y1-ge.y2).^2) * fontHeight)*2 + 1;
xD = (ge.x2 - ge.x1) / (numPts - 1);
yD = (ge.y2 - ge.y1) / (numPts - 1);
xS = ge.x1;
yS = ge.y1;
for j = 1:numPts
coords = [coords round(fontHeight * [xS + (j-1)*xD; yS + (j-1)*yD])];
end
otherwise
warning('matprint:getCoordinates:getCharCoordinates:unknownEntity', 'Unknown geometric entity ''%c''', ge.type);
end
end
end
|
|
Contact us