Comments (5)
Hi @vicjalan,
Actually it's not possible to set letter spacing, because of GD limitation.
I just try to make a workaround and add a $spacing
parameter to ImageWorkshopLayer::write
function.
I just push a "feature/font-spacing" branch.
If you want, feel free to give me a feedback.
from imageworkshop.
Hi jdecool,
Thanks for looking into this. I downloaded the updated code from the "feature/font-spacing" branch. I tried adding a value for the $spacing parameter but no matter the value I just get a black box around the text but no spacing is applied.
The line of code looks like(where 5 should be the value for $spacing):
$powerLayer = ImageWorkshop::initTextLayer('POWER', 'Resources\fonts\berlin-sans-fb-demi-bold.ttf', 23, 'ffffff', 0, 5);
Thanks again!
from imageworkshop.
Hi jdecool,
I understand what's happening now. The function initTextLayer doesn't have the $spacing parameter defined, the last parameter it has is $backgroundColor which is why the color was changing instead of adjusting the width.
I added the $spacing parameter to the initTextLayer function. However the dimensions of the text string is being looked up before the write function. So what this means is that the layer's width/height is being determined by the string length so when the letters are broken up and re-assembled with the spacing the text appears cut off.
I'm not sure if I'm explaining myself correctly but here is what I changed:
public static function initTextLayer($text, $fontPath, $fontSize = 13, $fontColor = 'ffffff', $textRotation = 0, $backgroundColor = null, $spacing = 0)
{
$textDimensions = ImageWorkshopLib::getTextBoxDimension($fontSize, $textRotation, $fontPath, $text);
$layer = static::initVirginLayer($textDimensions['width'], $textDimensions['height'], $backgroundColor);
$layer->write($text, $fontPath, $fontSize, $fontColor, $textDimensions['left'], $textDimensions['top'], $textRotation, $spacing);
return $layer;
}
Also if I set any text rotation it looks like so
from imageworkshop.
Thanks for your feedback.
I just try to write a quick POC.
I'm going to continue this feature next week.
from imageworkshop.
Just checking in on this to see letter spacing is now part of latest build.
from imageworkshop.
Related Issues (20)
- Move documentation to github repo HOT 4
- Fatal error: Uncaught Error: Class 'PHPImageWorkshop\Core\ImageWorkshopLayer' HOT 11
- Issue release in packageist HOT 1
- Right align text HOT 1
- Documentation Issues
- How to write Multi Line text
- GifCreator doesn't work
- White or Black bars with PNG and transparent background
- Webp support HOT 4
- Opening an optimized PNG (256 colors) result a grey block HOT 1
- Is it possible to wrap text to certain width ??
- GifCreator and global color palette?
- resizeToCover, like in css?
- PHP8 uses GDImage object instead resource HOT 4
- PHP Fatal error: Uncaught Error: Class "packages\PHPImageWorkshop\ImageWorkshop" not found HOT 1
- Problems with php 8.1 HOT 3
- Fix in convertHexToRGB method HOT 2
- Php Image Workshop supporting 8.1.13 or not HOT 1
- PHP deprecated function convertHexToRGB at php 8.1 HOT 7
- Working with grayscale png images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imageworkshop.