text2im

版本 2.0.0.0 (297.1 KB) 作者: Rik
Convert text to image
106.0 次下载
更新时间 2023/9/14

text2im documentation

View text2im on File Exchange Open in MATLAB Online

Table of contents

Description

This function will convert a string or char array to an image. There are several fonts implemented, each with their own license and number of included characters. All fonts are free to use in some form, but if you plan to use it on a large scale or for commercial purposes you should check the license of the specific font you want to use.

The list of included characters is based on a relatively arbitrary selection from three Wikipedia pages: general characters, newline characters, whitespace characters.

The list of actually available characters depends on the chosen font.

Fonts

The font images were generated using XeTeX and ghostscript.

Font ID Description and license Character size
'cmu_typewriter_text' This typeface contains 365 characters. This is a public domain typeface. [link] size=90x55
'cmu_concrete' This typeface contains 364 characters. This is a public domain typeface. [link] size=90x75
'ascii' This typeface contains only 94 characters (all printable chars below 127). This typeface was previously published in the text2im() (published on the FileExchange by Tobias Kiessling). [link] size=20x18
'droid_sans_mono' This typeface contains 411 characters and has an Apache License (Version 2.0). [link] size=95x51
'ibm_plex_mono' This typeface contains 376 characters and has an SIL Open Font License. [link] size=95x51
'liberation_mono' This typeface contains 415 characters and has a GNU General Public License. [link] size=95x51
'monoid' This typeface contains 398 characters and has an MIT License. [link] size=95x51

Matlab/Octave

Syntax

imtext = text2im(text)
imtext = text2im(text,font)
imtext = text2im(text,options)
imtext = text2im(text,Name,Value)

Output arguments

Argument Description
imtext A logical array containing the text image. The size is dependent on the font.

Input arguments

Argument Description
text The text to be converted can be supplied as char, string, or cellstr. Which characters are allowed is determined by the font. However, all fonts contain the printable and blank characters below 127. Any non-standard newline characters are ignored (i.e. LF/CR/CRLF are parsed as newline). Non-scalar inputs (or non-row vector inputs in the case of char) are allowed, but might not return the desired result.
font This syntax option exists for backwards compatibility. It is equivalent to the Name,Value syntax.
Name,Value The settings below can be entered with a Name,Value syntax.
options Instead of the Name,Value, parameters can also be entered in a struct. Missing fields will be set to the default values.

Name,Value pairs

Argument Description
font Font name as char array. The currently implemented options are cmu_typewriter_text (default), cmu_concrete, ascii, droid_sans_mono, ibm_plex_mono, liberation_mono, and monoid.
TranslateRichText Attempt to convert rich text characters missing from the currently selected font to normal characters. As an example, this converts a superscript 4 to a normal 4, but leaves a superscript 3 as-is (except with the 'ascii' font).
This is set to false automatically if there is not rich text. [default=true;]

Compatibility, version info, and licence

Compatibility considerations:

  • Multi-line inputs may have more trailing blank elements than intended. This is especially true for characters encoded with multiple elements (>127 for Octave and >65535 for Matlab).
Test suite result Windows Linux MacOS
Matlab R2023a W11 : Pass
Matlab R2022b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2022a W11 : Pass
Matlab R2021b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2021a W11 : Pass
Matlab R2020b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2020a W11 : Pass
Matlab R2019b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2019a W11 : Pass
Matlab R2018a W11 : Pass ubuntu_22.04 : Pass
Matlab R2017b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2016b W11 : Pass ubuntu_22.04 : Pass Monterey : Pass
Matlab R2015a W11 : Pass ubuntu_22.04 : Pass
Matlab R2013b W11 : Pass
Matlab R2007b W11 : Pass
Matlab 6.5 (R13) W11 : Pass
Octave 8.2.0 W11 : Pass
Octave 7.2.0 W11 : Pass
Octave 6.2.0 W11 : Pass raspbian_11 : Pass Catalina : Pass
Octave 5.2.0 W11 : Pass
Octave 4.4.1 W11 : Pass Catalina : Pass
Version: 2.0.0
Date:    2023-09-14
Author:  H.J. Wisselink
Licence: CC by-nc-sa 4.0 ( https://creativecommons.org/licenses/by-nc-sa/4.0 )
Email = 'h_j_wisselink*alumnus_utwente_nl';
Real_email = regexprep(Email,{'*','_'},{'@','.'})

Test suite

The tester is included so you can test if your own modifications would introduce any bugs. These tests form the basis for the compatibility table above. Note that functions may be different between the tester version and the normal function. Make sure to apply any modifications to both.

引用格式

Rik (2024). text2im (https://github.com/thrynae/text2im/releases/tag/v2.0.0), GitHub. 检索时间: .

MATLAB 版本兼容性
创建方式 R2023a
兼容 R13SP1 到 R2023a 的版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
2.0.0.0

See release notes for this release on GitHub: https://github.com/thrynae/text2im/releases/tag/v2.0.0

1.1.0

See release notes for this release on GitHub: https://github.com/thrynae/text2im/releases/tag/v1.1.0

1.0.1

See release notes for this release on GitHub: https://github.com/thrynae/text2im/releases/tag/v1.0.1

0.0.1

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库